Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual
Product codes
SW006021-1
MPLAB
®
XC8 C Compiler User’s Guide
DS52053B-page 362
2012 Microchip Technology Inc.
Example
#include <strings.h>
#include <stdio.h>
void
main (void)
{
static char temp[] = "Here it is...";
char c = ’s’;
if(strchr(temp, c))
printf("Character %c was found in string\n", c);
else
printf("No character was found in string");
}
See Also
strrchr()
, strlen(), strcmp()
Return Value
A pointer to the first match found, or NULL if the character does not exist in the string.
Note
Although the function takes an integer argument for the character, only the lower 8 bits
of the value are used.
of the value are used.
STRCMP, STRICMP
Synopsis
#include <string.h>
int strcmp (const char * s1, const char * s2)
int stricmp (const char * s1, const char * s2)
Description
The
strcmp()
function compares its two, null terminated, string arguments and returns
a signed integer to indicate whether
s1
is less than, equal to or greater than
s2
. The
comparison is done with the standard collating sequence, which is that of the ASCII
character set.
character set.
The
stricmp()
function is the case-insensitive version of this function.
Example
#include <string.h>
#include <stdio.h>
void
main (void)
{
int i;
if((i = strcmp("ABC", "ABc")) < 0)
printf("ABC is less than ABc\n");
else if(i > 0)
printf("ABC is greater than ABc\n");
else
printf("ABC is equal to ABc\n");
}