函数名: memchr
功 能: 在数组的前n个字节中搜索字符
用 法: #include <stdio.h>
void *memchr(void *s, char ch, unsigned n);
程序例:
#include <string.h>
#include <stdio.h>
int main(void)
{
char str[17];
char *ptr;
strcpy(str, "This is a string");
ptr = memchr(str, 'r', strlen(str));
if (ptr)
printf("The character 'r' is at position: %d\n", ptr - str);
else
printf("The character was not found\n");
return 0;
}