Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
C 如何检查一个字符串是否包含在另一个字符串中?_C_Substring_String Comparison - Fatal编程技术网

C 如何检查一个字符串是否包含在另一个字符串中?

C 如何检查一个字符串是否包含在另一个字符串中?,c,substring,string-comparison,C,Substring,String Comparison,python中的示例: >>> a="Sweet potato" >>> "potato" in a True 我想可能是strcmp,但strcmp必须是相同的匹配,否?strcmp用于确定两个字符串是否相同 如果你想知道一个字符串是否包含一个子字符串,有几种方法。一个很好的例子是Alter Mann所写的: if (strstr(str, "potato")) puts("True"); 如果是strstrstrstr,那么你可能想探索它们;上面的第一

python中的示例:

>>> a="Sweet potato"
>>> "potato" in a
True
我想可能是strcmp,但strcmp必须是相同的匹配,否?

strcmp用于确定两个字符串是否相同

如果你想知道一个字符串是否包含一个子字符串,有几种方法。一个很好的例子是Alter Mann所写的:

if (strstr(str, "potato")) puts("True");

如果是strstrstrstr,那么你可能想探索它们;上面的第一个谷歌点击^^^^是合适的,所以问答.sub字符串不会出现在我的头上。我们别再犯错误了。我要回去吃土豆无效,但无论哪种情况,这个答案都不值得投反对票。