strchr函數的實現

函數原型    char *strchr(const char* _Str,int _Val)函數

頭文件        #include <string.h>spa

功能           返回首次出現c的位置的指針,返回的地址是字符串在內存中隨機分配的地址再加上你所搜索的字符在字符串位置,若是s中不存在c則返回NULL指針


函數實現code

char * strchr(const char * _Str, int _Val)
{
    	const char * p = _Str;
	//若是*p==_Val或者*p爲'\0',退出循環
	while(*p!=_Val && *p)
		p++;
	return (char *)p;
}
相關文章
相關標籤/搜索