void * memchr ( const void * buffer, int c, size_t num );
Search buffer for a character.
Searches the first num bytes of memory block pointed by buffer for character c.
A pointer to the first occurrence of c in buffer.
If character is not found the function returns NULL.
Defined in ANSI-C.
ANSI-C++ standard specifies two different declarations for this function instead of the one included in ANSI-C:
const void * memchr ( const void * buffer, int c, size_t num );
void * memchr ( void * buffer, int c, size_t num );
Both have the same behavior as the original declaration.
/* memchr example */
char * pch;
char str = "Example string";
pch = (char*) memchr (str, 'l', strlen(str));
printf ("Character l was at position %d.\n", pch-str+1);
printf ("Character l was not found");
Character l was at position 6.
memcmp, memcpy, memset, strchr