SW006014 Microchip Technology, SW006014 Datasheet - Page 126

C COMPILER MPLAB FOR PIC24 MCU

SW006014

Manufacturer Part Number
SW006014
Description
C COMPILER MPLAB FOR PIC24 MCU
Manufacturer
Microchip Technology
Type
MPLAB® C Compilerr
Series
PIC24r
Datasheet

Specifications of SW006014

Supported Families
PIC24
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24
Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC24
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
DS51456E-page 122
strcmp
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Compares two strings.
<string.h>
int strcmp(const char *s1, const char *s2);
s1
s2
Returns a positive number if s1 is greater than s2, zero if s1 is equal to
s2, or a negative number if s1 is less than s2.
This function compares successive characters from s1 and s2 until
they are not equal or the null terminator is reached.
#include <string.h> /* for strcmp */
#include <stdio.h>
int main(void)
{
}
char buf1[50] = "Where is the time?";
char buf2[50] = "Where did they go?";
char buf3[50] = "Why?";
int res;
printf("buf1 : %s\n", buf1);
printf("buf2 : %s\n", buf2);
printf("buf3 : %s\n\n", buf3);
res = strcmp(buf1, buf2);
if (res < 0)
else if (res == 0)
else
printf("\n");
res = strcmp(buf1, buf3);
if (res < 0)
else if (res == 0)
else
printf("\n");
res = strcmp("Why?", buf3);
if (res < 0)
else if (res == 0)
else
printf("buf1 comes before buf2\n");
printf("buf1 and buf2 are equal\n");
printf("buf2 comes before buf1\n");
printf("buf1 comes before buf3\n");
printf("buf1 and buf3 are equal\n");
printf("buf3 comes before buf1\n");
printf("\"Why?\" comes before buf3\n");
printf("\"Why?\" and buf3 are equal\n");
printf("buf3 comes before \"Why?\"\n");
first string
second string
/* for printf */
© 2008 Microchip Technology Inc.

Related parts for SW006014