stcpbrk--在源字符串(s1)中找出最先含有搜索字符串(s2)中任一字符的位置并返回,若找不到则返回空指针。

来源:互联网 发布:人工智能 论坛 编辑:程序博客网 时间:2024/05/17 22:21
//用途:在源字符串(s1)中找出最先含有搜索字符串(s2)中任一字符的位置并返回,若找不到则返回空指针。char *strpbrk1(const char *strSrc, const char *str){assert(strSrc != NULL && str != NULL);const char *sc1,*sc2;for (sc1 = strSrc;*sc1 != '\0';++sc1){for (sc2 = str;*sc2 != '\0';++sc2){if (*sc1 == *sc2){return  (char *)sc1;}}}}int main(void){    char s[20] = "hello world";char *t = "o";cout<<strpbrk(s,t);//output: o world    system("pause");    return 0;}


	
				
		
原创粉丝点击