函数原型 char *strchr(const char* _Str,int _Val)
头文件 #include <string.h>
功能 返回首次出现c的位置的指针,返回的地址是字符串在内存中随机分配的地址再加上你所搜索的字符在字符串位置,如果s中不存在c则返回NULL。
函数实现
char * strchr(const char * _Str, int _Val)
{
const char * p = _Str;
//如果*p==_Val或者*p为'\0',退出循环
while(*p!=_Val && *p)
p++;
return (char *)p;
}