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

📄 stdstring_details.html

📁 ssd5 数据结构的课件
💻 HTML
📖 第 1 页 / 共 2 页
字号:
    printf( "Hello, %s\n", title );</pre>    <i>Related topics:</i><br>     <strong><a href="#strchr">strchr()</a>, <a href="#strcmp">strcmp()</a>, and <a href=    "#strcpy">strcpy()</a>.</strong>     <hr>    <h2><a name="strchr">strchr</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strchr( const char *str, int ch );</pre>        </td>      </tr>    </table>    <p>The function strchr() returns a pointer to the first occurence of <i>ch</i> in <i>str</i>, or NULL if    <i>ch</i> is not found.</p>    <i>Related topics:</i><br>     <strong><a href="#strpbrk">strpbrk()</a>, <a href="#strspn">strspn()</a>, <a href=    "#strstr">strstr()</a>, and <a href="#strtok">strtok()</a>.</strong>     <hr>    <h2><a name="strcmp">strcmp</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  int strcmp( const char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The function strcmp() compares <i>str1</i> and <i>str2</i>, then returns:</p>    <table bgcolor="#eeeeff">      <tr>        <td><strong>Return value</strong></td>        <td><strong>Explanation</strong></td>      </tr>      <tr>        <td>less than 0</td>        <td>str1 is less than str2</td>      </tr>      <tr>        <td>equal to 0</td>        <td>str1 is equal to str2</td>      </tr>      <tr>        <td>greater than 0</td>        <td>str1 is greater than str2</td>      </tr>    </table>    <p>For example:</p><pre>    printf( "Enter your name: " );    scanf( "%s", name );    if( strcmp( name, "Mary" ) == 0 )      printf( "Hello, Dr. Mary!\n" );</pre>    <i>Related topics:</i><br>     <strong><a href="#memcmp">memcmp()</a>, <a href="#strchr">strchr()</a>, <a href="#strcpy">strcpy()</a>,    and <a href="#strncmp">strncmp()</a>.</strong>     <hr>    <h2><a name="strcoll">strcoll</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  int strcoll( const char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The strcoll() function compares <i>str1</i> and <i>str2</i>, much like <a href="#strcmp">strcmp</a>.    However, strcoll() performs the comparison using the locale specified by the <a href=    "stddate_details.html#setlocale">setlocale()</a> function.</p>    <hr>    <h2><a name="strcpy">strcpy</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strcpy( char *to, const char *from );</pre>        </td>      </tr>    </table>    <p>The strcpy() function copies characters in the string <i>from</i> to the string <i>to</i>, including    the null termination. The return value is <i>to</i>.</p>    <i>Related topics:</i><br>     <strong><a href="#memcpy">memcpy()</a>, <a href="#strchr">strchr()</a>, <a href="#strcmp">strcmp()</a>,    <a href="#strncmp">strncmp()</a>, and <a href="#strncpy">strncpy()</a>.</strong>     <hr>    <h2><a name="strcspn">strcspn</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  size_t strcspn( const char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The function strcspn() returns the index of the first character in <i>str1</i> that matches any of the    characters in <i>str2</i>.</p>    <i>Related topics:</i><br>     <strong><a href="#strrchr">strrchr()</a>, <a href="#strpbrk">strpbrk()</a>, <a href=    "#strstr">strstr()</a>, and <a href="#strtok">strtok()</a>.</strong>     <hr>    <h2><a name="strerror">strerror</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strerror( int num );</pre>        </td>      </tr>    </table>    <p>The function strerror() returns an "implementation defined string corresponding to <i>num</i>."</p>    <hr>    <h2><a name="strlen">strlen</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  size_t strlen( char *str );</pre>        </td>      </tr>    </table>    <p>The strlen() function returns the length of <i>str</i> (determined by the number of characters before    null termination).</p>    <i>Related topics:</i><br>     <strong><a href="#memcpy">memcpy()</a>, <a href="#strchr">strchr()</a>, <a href="#strcmp">strcmp()</a>,    and <a href="#strncmp">strncmp()</a>.</strong>     <hr>    <h2><a name="strncat">strncat</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strncat( char *str1, const char *str2, size_t count );</pre>        </td>      </tr>    </table>    <p>The function strncat() concatenates at most <i>count</i> characters of <i>str2</i> onto <i>str1</i>,    adding a null termination. The resulting string is returned.</p>    <i>Related topics:</i><br>     <strong><a href="#strcat">strcat()</a>, <a href="#strnchr">strnchr()</a>, <a href=    "#strncmp">strncmp()</a>, and <a href="#strncpy">strncpy()</a>.</strong>     <hr>    <h2><a name="strncmp">strncmp</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  int strncmp( const char *str1, const char *str2, size_t count );</pre>        </td>      </tr>    </table>    <p>The strncmp() function compares at most <i>count</i> characters of <i>str1</i> and <i>str2</i>. The    return value is as follows:</p>    <table bgcolor="#eeeeff">      <tr>        <td><strong>Return value</strong></td>        <td><strong>Explanation</strong></td>      </tr>      <tr>        <td>less than 0</td>        <td>str1 is less than str2</td>      </tr>      <tr>        <td>equal to 0</td>        <td>str1 is equal to str2</td>      </tr>      <tr>        <td>greater than 0</td>        <td>str1 is greater than str2</td>      </tr>    </table>    <p>If there are less than <i>count</i> characters in either string, then the comparison will stop after    the first null termination is encountered.</p>    <i>Related topics:</i><br>     <strong><a href="#strcmp">strcmp()</a>, <a href="#strnchr">strnchr()</a>, and <a href=    "#strncpy">strncpy()</a>.</strong>     <hr>    <h2><a name="strncpy">strncpy</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strncpy( char *to, const char *from, size_t count );</pre>        </td>      </tr>    </table>    <p>The strncpy() function copies at most <i>count</i> characters of <i>from</i> to the string <i>to</i>.    If <i>from</i> has less than <i>count</i> characters, the remainder is padded with '\0' characters. The    return value is the resulting string.</p>    <i>Related topics:</i><br>     <strong><a href="#memcpy">memcpy()</a>, <a href="#strchr">strchr()</a>, <a href=    "#strncat">strncat()</a>, and <a href="#strncmp">strncmp()</a>.</strong>     <hr>    <h2><a name="strpbrk">strpbrk</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strpbrk( const char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The function strpbrk() returns a pointer to the first ocurrence in <i>str1</i> of any character in    <i>str2</i>, or NULL if none are present.</p>    <i>Related topics:</i><br>     <strong><a href="#strspn">strspn()</a>, <a href="#strrchr">strrchr()</a>, <a href=    "#strstr">strstr()</a>, and <a href="#strtok">strtok()</a>.</strong>     <hr>    <h2><a name="strrchr">strrchr</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strrchr( const char *str, int ch );</pre>        </td>      </tr>    </table>    <p>The function strrchr() returns a pointer to the last occurrence of <i>ch</i> in <i>str</i>, or    <strong>NULL</strong> if no match is found.</p>    <i>Related topics:</i><br>    <strong><a href="#strpbrk">strpbrk()</a>, <a href="#strspn">strspn()</a>, <a href="#strstr">strstr()</a>,    <a href="#strtok">strtok()</a>,</strong>     <hr>    <h2><a name="strspn">strspn</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  size_t strspn( const char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The strspn() function returns the index of the first character in <i>str1</i> that doesn't match any    character in <i>str2</i>.</p>    <i>Related topics:</i><br>    <strong><a href="#strpbrk">strpbrk()</a>, <a href="#strrchr">strrchr()</a>, <a href=    "#strstr">strstr()</a>, <a href="#strtok">strtok()</a>,</strong>     <hr>    <h2><a name="strstr">strstr</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strstr( const char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The function strstr() returns a pointer to the first occurrence of <i>str2</i> in <i>str1</i>, or    <strong>NULL</strong> if no match is found.</p>    <i>Related topics:</i><br>    <strong><a href="#strchr">strchr()</a>, <a href="#strcspn">strcspn()</a>, <a href=    "#strpbrk">strpbrk()</a>, <a href="#strspn">strspn()</a>, <a href="#strtok">strtok()</a>, <a href=    "#strrchr">strrchr()</a>,</strong>     <hr>    <h2><a name="strtod">strtod</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdlib.h&gt;  double strtod( const char *start, char **end );</pre>        </td>      </tr>    </table>    <p>The function strtod() returns whatever it encounters first in <i>start</i> as a double. <i>end</i> is    set to point at whatever is left in <i>start</i> after that double. If overflow occurs, strtod() returns    either <strong>HUGE_VAL</strong> or <strong>-HUGE_VAL</strong>.</p>    <i>Related topics:</i><br>     <strong><a href="#atof">atof()</a></strong>     <hr>    <h2><a name="strtok">strtok</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strtok( char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The strtok() function returns a pointer to the next "token" in <i>str1</i>, where <i>str2</i> contains    the delimiters that determine the token. strtok() returns NULL if no token is found. In order to convert    a string to tokens, the first call to strtok() should have <i>str1</i> point to the string to be    tokenized. All calls after this should have <i>str1</i> be NULL.</p>    <p>For example:</p><pre>    char str[] = "now # is the time for all # good men to come to the # aid of their country";    char delims[] = "#";    char *result = NULL;    result = strtok( str, delims );    while( result != NULL ) {        printf( "result is \"%s\"\n", result );        result = strtok( NULL, delims );    }</pre>    <p>The above code will display the following output:</p><pre>    result is "now "    result is " is the time for all "    result is " good men to come to the "    result is " aid of their country"</pre>    <i>Related topics:</i><br>     <strong><a href="#strchr">strchr()</a>, <a href="#strcspn">strcspn()</a>, <a href=    "#strpbrk">strpbrk()</a>, <a href="#strrchr">strrchr()</a>, and <a href="#strspn">strspn()</a>.</strong>     <hr>    <h2><a name="strtol">strtol</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdlib.h&gt;  long strtol( const char *start, char **end, int base );</pre>        </td>      </tr>    </table>    <p>The strtol() function returns whatever it encounters first in <i>start</i> as a long, doing the    conversion to <i>base</i> if necessary. <i>end</i> is set to point to whatever is left in <i>start</i>    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>    <i>Related topics:</i><br>     <strong><a href="#atol">atol()</a>.</strong>     <hr>    <h2><a name="strtoul">strtoul</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdlib.h&gt;  unsigned long strtoul( const char *start, char **end, int base );</pre>        </td>      </tr>    </table>    <p>The function strtoul() behaves exactly like <a href="#strtol">strtol()</a>, except that it returns an    unsigned long rather than a mere long.</p>    <i>Related topics:</i><br>     <strong><a href="#strtol">strtol()</a></strong>     <hr>    <h2><a name="strxfrm">strxfrm</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  size_t strxfrm( char *str1, const char *str2, size_t num );</pre>        </td>      </tr>    </table>    <p>The strxfrm() function manipulates the first <i>num</i> characters of <i>str2</i> and stores them in    <i>str1</i>. The result is such that if a <a href="#strcoll">strcoll()</a> is performed on <i>str1</i>    and the old <i>str2</i>, you will get the same result as with a <a href="#strcmp">strcmp()</a>.</p>    <i>Related topics:</i><br>    <strong><a href="#strcmp">strcmp()</a>, <a href="#strcoll">strcoll()</a>,</strong>     <hr>    <h2><a name="tolower">tolower</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int tolower( int ch );</pre>        </td>      </tr>    </table>    <p>The function tolower() returns the lowercase version of the character <i>ch</i>.</p>    <i>Related topics:</i><br>    <strong><a href="#toupper">toupper()</a>,</strong>     <hr>    <h2><a name="toupper">toupper</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int toupper( int ch );</pre>        </td>      </tr>    </table>    <p>The toupper() function returns the uppercase version of the character <i>ch</i>.</p>    <i>Related topics:</i><br>    <strong><a href="#tolower">tolower()</a>,</strong>  </body></html>

⌨️ 快捷键说明

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