//用途:在源字符串(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; }
stcpbrk--在源字符串(s1)中找出最先含有搜索字符串(s2)中任一字符的位置并返回,若找不到则返回空指针。
最新推荐文章于 2022-03-28 23:38:46 发布