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

📄 all.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
📖 第 1 页 / 共 3 页
字号:
  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strncat  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  char *strncat( char *str1, const char *str2, size_t count );</pre>  <p>The function strncat() concatenates at most <em>count</em>  characters of <em>str2</em> onto <em>str1</em>, adding a null  termination. The resulting string is returned.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="strcat.html">strcat</a><br>    <a href="strchr.html">strchr</a><br>    <a href="strncmp.html">strncmp</a><br>    <a href="strncpy.html">strncpy</a>  </div>  <p>Another set of related (but non-standard) functions are <a  href="http://en.wikipedia.org/wiki/Strlcpy">strlcpy and  strlcat</a>.</p>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strncmp  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  int strncmp( const char *str1, const char *str2, size_t count );</pre>  <p>The strncmp() function compares at most <em>count</em> characters  of <em>str1</em> and <em>str2</em>. The return value is as  follows:</p>  <table class="code-table">    <tr>      <th class="code-table-th">Return value</th>      <th class="code-table-th">Explanation</th>    </tr>    <tr>      <td class="code-table-td">less than 0</td>      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is less than      &#39;&#39;str2&#39;&#39;</td>    </tr>    <tr>      <td class="code-table-td">equal to 0</td>      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is equal to      &#39;&#39;str2&#39;&#39;</td>    </tr>    <tr>      <td class="code-table-td">greater than 0</td>      <td class="code-table-td">&#39;&#39;str1&#39;&#39; is greater      than str2&#39;&#39;</td>    </tr>  </table>  <p>If there are less than <em>count</em> characters in either string,  then the comparison will stop after the first null termination is  encountered.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="strchr.html">strchr</a><br>    <a href="strcmp.html">strcmp</a><br>    <a href="strcpy.html">strcpy</a><br>    <a href="strlen.html">strlen</a><br>    <a href="strncat.html">strncat</a><br>    <a href="strncpy.html">strncpy</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strncpy  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  char *strncpy( char *to, const char *from, size_t count );</pre>  <p>The strncpy() function copies at most <em>count</em> characters of  <em>from</em> to the string <em>to</em>. If from has less than  <em>count</em> characters, the remainder is padded with &#39;\0&#39;  characters. The return value is the resulting string.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="memcpy.html">memcpy</a><br>    <a href="strchr.html">strchr</a><br>    <a href="strcpy.html">strcpy</a><br>    <a href="strncat.html">strncat</a><br>    <a href="strncmp.html">strncmp</a>  </div>  <p>Another set of related (but non-standard) functions are <a  href="http://en.wikipedia.org/wiki/Strlcpy">strlcpy and  strlcat</a>.</p>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strpbrk  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  char* strpbrk( const char* str1, const char* str2 );</pre>  <p>The function strpbrk() returns a pointer to the first ocurrence in  <em>str1</em> of any character in <em>str2</em>, or  <strong>NULL</strong> if no such characters are present.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    (C++ Algorithms) <a href=    "../cppalgorithm/find_first_of.html">find_first_of</a><br>    <a href="strchr.html">strchr</a><br>    <a href="strcspn.html">strcspn</a><br>    <a href="strrchr.html">strrchr</a><br>    <a href="strspn.html">strspn</a><br>    <a href="strstr.html">strstr</a><br>    <a href="strtok.html">strtok</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strrchr  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  char *strrchr( const char *str, int ch );</pre>  <p>The function strrchr() returns a pointer to the last occurrence of  <em>ch</em> in <em>str</em>, or <strong>NULL</strong> if no match is  found.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="strcspn.html">strcspn</a><br>    <a href="strpbrk.html">strpbrk</a><br>    <a href="strspn.html">strspn</a><br>    <a href="strstr.html">strstr</a><br>    <a href="strtok.html">strtok</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strspn  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  size_t strspn( const char *str1, const char *str2 );</pre>  <p>The strspn() function returns the index of the first character in  <em>str1</em> that doesn&#39;t match any character in  <em>str2</em>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="strchr.html">strchr</a><br>    <a href="strpbrk.html">strpbrk</a><br>    <a href="strrchr.html">strrchr</a><br>    <a href="strstr.html">strstr</a><br>    <a href="strtok.html">strtok</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <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><hr>  <div class="name-format">    strtod  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;stdlib.h&gt;  double strtod( const char *start, char **end );</pre>  <p>The function strtod() returns whatever it encounters first in  <em>start</em> as a double. <em>end</em> is set to point at whatever  is left in <em>start</em> after that double. If overflow occurs,  strtod() returns either <strong>HUGE_VAL</strong> or  -<strong>HUGE_VAL</strong>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="atof.html">atof</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strtok  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  char *strtok( char *str1, const char *str2 );</pre>  <p>The strtok() function returns a pointer to the next  &quot;token&quot; in <em>str1</em>, where <em>str2</em> contains the  delimiters that determine the token. strtok() returns  <strong>NULL</strong> if no token is found. In order to convert a  string to tokens, the first call to strtok() should have  <em>str1</em> point to the string to be tokenized. All calls after  this should have <em>str1</em> be <strong>NULL</strong>.</p>  <p>For example:</p>  <pre class="example-code">   char str[] = &quot;now # is the time for all # good men to come to the # aid of their country&quot;;   char delims[] = &quot;#&quot;;   char *result = <strong>NULL</strong>;   result = strtok( str, delims );   while( result != <strong>NULL</strong> ) {       printf( &quot;result is \&quot;%s\&quot;\n&quot;, result );       result = strtok( <strong>NULL</strong>, delims );   }            </pre>  <p>The above code will display the following output:</p>  <pre class="example-code">   result is &quot;now &quot;   result is &quot; is the time for all &quot;   result is &quot; good men to come to the &quot;   result is &quot; aid of their country&quot;          </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <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="strstr.html">strstr</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strtol  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;stdlib.h&gt;  long strtol( const char *start, char **end, int base );</pre>  <p>The strtol() function returns whatever it encounters first in  <em>start</em> as a long, doing the conversion to <em>base</em> if  necessary. <em>end</em> is set to point to whatever is left in  <em>start</em> after the long. If the result can not be represented  by a long, then strtol() returns either <strong>LONG_MAX</strong> or  <strong>LONG_MIN</strong>. Zero is returned upon error.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="atol.html">atol</a><br>    <a href="strtoul.html">strtoul</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strtoul  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;stdlib.h&gt;  unsigned long strtoul( const char *start, char **end, int base );</pre>  <p>The function strtoul() behaves exactly like <a href=  "strtol.html">strtol</a>(), except that it returns an unsigned long  rather than a mere long.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="strtol.html">strtol</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    strxfrm  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;string.h&gt;  size_t strxfrm( char *str1, const char *str2, size_t num );</pre>  <p>The strxfrm() function manipulates the first <em>num</em>  characters of <em>str2</em> and stores them in <em>str1</em>. The  result is such that if a <a href="strcoll.html">strcoll</a>() is  performed on <em>str1</em> and the old <em>str2</em>, you will get  the same result as with a <a href="strcmp.html">strcmp</a>().</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="strcmp.html">strcmp</a><br>    <a href="strcoll.html">strcoll</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    tolower  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;ctype.h&gt;  int tolower( int ch );</pre>  <p>The function tolower() returns the lowercase version of the  character <em>ch</em>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="isupper.html">isupper</a><br>    <a href="toupper.html">toupper</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    toupper  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;ctype.h&gt;  int toupper( int ch );</pre>  <p>The toupper() function returns the uppercase version of the  character <em>ch</em>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="tolower.html">tolower</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr></body></html>

⌨️ 快捷键说明

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