uTools-Manuals/docs/c/strstr.html
2019-04-21 11:50:48 +08:00

40 lines
967 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1>字符串函数 - strstr</h1>
<p>原型extern char *strstr(char *haystack, char *needle);</p>
<p>用法:#include &lt;string.h></p>
<p>功能从字符串haystack中寻找needle第一次出现的位置不比较结束符NULL)。</p>
<p>说明返回指向第一次出现needle位置的指针如果没找到则返回NULL。</p>
举例:<pre><code class="language-c">
// strstr.c
#include &lt;syslib.h>
#include &lt;string.h>
main()
{
char *s="Golden Global View";
char *l="lob";
char *p;
clrscr();
p=strstr(s,l);
if(p)
printf("%s",p);
else
printf("Not Found!");
getchar();
return 0;
}
</code></pre>相关函数:<a href="strchr.html">strchr</a>,<a href="strpbrk.html">strpbrk</a>,<a href="strtok.html">strtok</a>