Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用'搜索子字符串;srtchr()';_C_String_Substring_String Search_Strchr - Fatal编程技术网

使用'搜索子字符串;srtchr()';

使用'搜索子字符串;srtchr()';,c,string,substring,string-search,strchr,C,String,Substring,String Search,Strchr,使用函数strchr是否可以搜索字符串中的子字符串而不是字符 示例: 与此相反: int r=strchr("Hello World",'W'); 这可以用于: int r=strchr("Hello World","World"); 没有。你可以用它 没有。你可以用它 使用函数“strchr()”是否可以搜索 字符串中的“substring”而不是“character” 示例: 而不是这个:intr=strchr(“helloworld”,“W”) 是否可以使用:int r=strchr(

使用函数
strchr
是否可以搜索字符串中的子字符串而不是字符

示例:

与此相反:

int r=strchr("Hello World",'W');
这可以用于:

int r=strchr("Hello World","World");
没有。你可以用它

没有。你可以用它

使用函数“strchr()”是否可以搜索 字符串中的“substring”而不是“character”

示例:

而不是这个:intr=strchr(“helloworld”,“W”)

是否可以使用:int r=strchr(“你好,世界”,“世界”)

不,就是这样

还请注意,它不会返回
int
,而是返回指向所搜索字符的
char*
指针,如果未找到,则返回
NULL
。编译器警告的存在是有原因的

使用函数“strchr()”是否可以搜索 字符串中的“substring”而不是“character”

示例:

而不是这个:intr=strchr(“helloworld”,“W”)

是否可以使用:int r=strchr(“你好,世界”,“世界”)

不,就是这样

还请注意,它不会返回
int
,而是返回指向所搜索字符的
char*
指针,如果未找到,则返回
NULL
。编译器警告的存在是有原因的…

为此使用strstr

请使用此链接作为参考

为此使用strstr

请使用此链接作为参考


strstr()也可以与“unsigned char”一起使用吗?@nivedithanatarajan,只要传递的两个参数都是
'\0'
-终止的字符串,是的。strstr()也可以与“unsigned char”一起使用吗?@nivedithanatarajan,只要传递的两个参数都是
'\0'
-终止的字符串,是的。
char *substring = strstr("Hello World","World");