C Reference String Operation: memchr()
The memchr() function returns a pointer to the first occurrence of c in the first n bytes of a memory area.
Usage:
void *memchr(const void *s, int c, size_t n);
If c does not occur, a null pointer is returned.
memchr() source code example:
#include<stdio.h>
#include<string.h>
main()
{
char line[100];
strcpy(line, "aaabccc");
if( memchr(line,'b',strlen(line)) == NULL )
printf("b not found\n");
else
printf("b is found\n");
}
Output of the example:
b is found
This entry was posted in C Reference string.h Functions.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Tweet This! or use
to share this post with others.