使用该函数strchr
是否可以在字符串中搜索子字符串而不是字符?
例子:
而不是这个:
int r=strchr("Hello World",'W');
这个可以用吗:
int r=strchr("Hello World","World");
使用该函数strchr
是否可以在字符串中搜索子字符串而不是字符?
例子:
而不是这个:
int r=strchr("Hello World",'W');
这个可以用吗:
int r=strchr("Hello World","World");
使用函数“strchr()”是否可以在字符串中搜索“子字符串”而不是“字符”?
例子 :
而不是这个: int r=strchr("Hello World",'W');
可以使用: int r=strchr("Hello World","World");
不,那strstr()
是为了。
另请注意,strchr()
它不返回int
,它返回一个char *
指向所搜索字符的指针,或者NULL
如果未找到。编译器警告的存在是有原因的......
没有。你可以使用strstr
它
char *substring = strstr("Hello World","World");