⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strstr.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta name="generator" content=  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">  <title>strstr</title>  <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table>  <tr>  <td>  <div class="body-content">  <div class="header-box">    <a href="../index.html">cppreference.com</a> &gt; <a href=    "index.html">Standard C String and Character</a> &gt; <a href=    "strstr.html">strstr</a>  </div>  <div class="name-format">    strstr  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  char *strstr( const char *str1, const char *str2 );</pre>  <p>The function strstr() returns a pointer to the first occurrence  of <em>str2</em> in <em>str1</em>, or <strong>NULL</strong> if no  match is found.  If the length of <em>str2</em> is zero, then  strstr() will simply return <em>str1</em>.  </p>  <p>For example, the following code checks for the existence of one  string within another string:</p>  <pre class="example-code">  char* str1 = "this is a string of characters";  char* str2 = "a string";  char* result = strstr( str1, str2 );  if( result == NULL ) printf( "Could not find '%s' in '%s'\n", str2, str1 );  else printf( "Found a substring: '%s'\n", result );</pre>  <p>When run, the above code displays this output:</p>  <pre class="example-code">  Found a substring: 'a string of characters'</pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="memchr.html">memchr</a><br>    <a href="strchr.html">strchr</a><br>    <a href="strcspn.html">strcspn</a><br>    <a href="strpbrk.html">strpbrk</a><br>    <a href="strrchr.html">strrchr</a><br>    <a href="strspn.html">strspn</a><br>    <a href="strtok.html">strtok</a>  </div>  </div>  </td>    </tr>  </table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -