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

📄 stdstring_details.html

📁 ssd5 数据结构的课件
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <meta name="generator" content="HTML Tidy for Linux/x86 (vers 1st October 2002), see www.w3.org">    <title>Standard C String &amp; Character</title>  </head>  <body bgcolor="#ffffff">    <table width="100%" bgcolor="#eeeeff">      <tr>        <td><a href="index.html">cppreference.com</a> -&gt; <a href="stdstring.html">Standard C String &amp;        Character</a> -&gt; Details</td>      </tr>    </table>    <h1>Standard C String &amp; Character</h1>    <hr>    <h2><a name="atof">atof</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdlib.h&gt;  double atof( const char *str );</pre>        </td>      </tr>    </table>    <p>The function atof() converts <i>str</i> into a double, then returns that value. <i>str</i> must start    with a valid number, but can be terminated with any non-numerical character, other than "E" or "e". For    example,</p><pre>    x = atof( "42.0is_the_answer" );</pre>    <p>results in x being set to 42.0.</p>    <i>Related topics:</i><br>     <strong><a href="#atoi">atoi()</a> and <a href="#atol">atol()</a>.</strong>     <hr>    <h2><a name="atoi">atoi</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdlib.h&gt;  int atoi( const char *str );</pre>        </td>      </tr>    </table>    <p>The atoi() function converts <i>str</i> into an integer, and returns that integer. <i>str</i> should    start with some sort of number, and atoi() will stop reading from <i>str</i> as soon as a non-numerical    character has been read. For example,</p><pre>    i = atoi( "512.035" );</pre>    <p>would result in i being set to 512.</p>    <i>Related topics:</i><br>     <strong><a href="#atof">atof()</a> and <a href="#atol">atol()</a>.</strong>     <hr>    <h2><a name="atol">atol</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdlib.h&gt;  long atol( const char *str );</pre>        </td>      </tr>    </table>    <p>The function atol() converts <i>str</i> into a long, then returns that value. atol() will read from    <i>str</i> until it finds any character that should not be in a long. The resulting truncated value is    then converted and returned. For example,</p><pre>    x = atol( "1024.0001" );</pre>    <p>results in x being set to 1024L.</p>    <i>Related topics:</i><br>     <strong><a href="#atof">atof()</a> and <a href="#atoi">atoi()</a>.</strong>     <hr>    <h2><a name="isalnum">isalnum</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isalnum( int ch );</pre>        </td>      </tr>    </table>    <p>The function isalnum() returns non-zero if its argument is a numeric digit or a letter of the    alphabet. Otherwise, zero is returned.</p><pre>    char c;    scanf( "%c", &amp;c );    if( isalnum(c) )      printf( "You entered the alphanumeric character %c\n", c );</pre>    <i>Related topics:</i><br>     <strong><a href="#isalpha">isalpha()</a>, <a href="#iscntrl">iscntrl()</a>, <a href=    "#isdigit">isdigit()</a>, <a href="#isgraph">isgraph()</a>, <a href="#isprint">isprint()</a>, <a href=    "#ispunct">ispunct()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="isalpha">isalpha</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isalpha( int ch );</pre>        </td>      </tr>    </table>    <p>The function isalpha() returns non-zero if its argument is a letter of the alphabet. Otherwise, zero    is returned.</p><pre>    char c;    scanf( "%c", &amp;c );    if( isalpha(c) )      printf( "You entered a letter of the alphabet\n" );</pre>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#iscntrl">iscntrl()</a>, <a href=    "#isdigit">isdigit()</a>, <a href="#isgraph">isgraph()</a>, <a href="#isprint">isprint()</a>, <a href=    "#ispunct">ispunct()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="iscntrl">iscntrl</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int iscntrl( int ch );</pre>        </td>      </tr>    </table>    <p>The iscntrl() function returns non-zero if its argument is a control character (between 0 and 0x1F or    equal to 0x7F). Otherwise, zero is returned.</p>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#isalpha">isalpha()</a>, <a href=    "#isdigit">isdigit()</a>, <a href="#isgraph">isgraph()</a>, <a href="#isprint">isprint()</a>, <a href=    "#ispunct">ispunct()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="isdigit">isdigit</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isdigit( int ch );</pre>        </td>      </tr>    </table>    <p>The function isdigit() returns non-zero if its argument is a digit between 0 and 9. Otherwise, zero is    returned.</p><pre>    char c;    scanf( "%c", &amp;c );    if( isdigit(c) )      printf( "You entered the digit %c\n", c );</pre>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#isalpha">isalpha()</a>, <a href=    "#iscntrl">iscntrl()</a>, <a href="#isgraph">isgraph()</a>, <a href="#isprint">isprint()</a>, <a href=    "#ispunct">ispunct()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="isgraph">isgraph</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isgraph( int ch );</pre>        </td>      </tr>    </table>    <p>The function isgraph() returns non-zero if its argument is any printable character other than a space    (if you can see the character, then isgraph() will return a non-zero value). Otherwise, zero is    returned.</p>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#isalpha">isalpha()</a>, <a href=    "#iscntrl">iscntrl()</a>, <a href="#isdigit">isdigit()</a>, <a href="#isprint">isprint()</a>, <a href=    "#ispunct">ispunct()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="islower">islower</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int islower( int ch );</pre>        </td>      </tr>    </table>    <p>The islower() function returns non-zero if its argument is a lowercase letter. Otherwise, zero is    returned.</p>    <i>Related topics:</i><br>     <strong><a href="#isupper">isupper()</a></strong>     <hr>    <h2><a name="isprint">isprint</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isprint( int ch );</pre>        </td>      </tr>    </table>    <p>The function isprint() returns non-zero if its argument is a printable character (including a space).    Otherwise, zero is returned.</p>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#isalpha">isalpha()</a>, <a href=    "#iscntrl">iscntrl()</a>, <a href="#isdigit">isdigit()</a>, <a href="#isgraph">isgraph()</a>, <a href=    "#ispunct">ispunct()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="ispunct">ispunct</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int ispunct( int ch );</pre>        </td>      </tr>    </table>    <p>The ispunct() function returns non-zero if its argument is a printing character but neither    alphanumeric nor a space. Otherwise, zero is returned.</p>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#isalpha">isalpha()</a>, <a href=    "#iscntrl">iscntrl()</a>, <a href="#isdigit">isdigit()</a>, <a href="#isgraph">isgraph()</a>, <a href=    "#isprint">isprint()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="isspace">isspace</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isspace( int ch );</pre>        </td>      </tr>    </table>    <p>The isspace() function returns non-zero if its argument is some sort of space (i.e. single space, tab,    vertical tab, form feed, carriage return, or newline). Otherwise, zero is returned.</p>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#isalpha">isalpha()</a>, <a href=    "#iscntrl">iscntrl()</a>, <a href="#isdigit">isdigit()</a>, <a href="#isgraph">isgraph()</a>, and <a    href="#ispunct">ispunct()</a>.</strong>     <hr>    <h2><a name="isupper">isupper</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isupper( int ch );</pre>        </td>      </tr>    </table>    <p>The isupper() function returns non-zero if its argument is an uppercase letter. Otherwise, zero is    returned.</p>    <i>Related topics:</i><br>     <strong><a href="#tolower">tolower()</a></strong>     <hr>    <h2><a name="isxdigit">isxdigit</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;ctype.h&gt;  int isxdigit( int ch );</pre>        </td>      </tr>    </table>    <p>The function isxdigit() returns non-zero if its argument is a hexidecimal digit (i.e. A-F, a-f, or    0-9). Otherwise, zero is returned.</p>    <i>Related topics:</i><br>     <strong><a href="#isalnum">isalnum()</a>, <a href="#isalpha">isalpha()</a>, <a href=    "#iscntrl">iscntrl()</a>, <a href="#isdigit">isdigit()</a>, <a href="#isgraph">isgraph()</a>, <a href=    "#ispunct">ispunct()</a>, and <a href="#isspace">isspace()</a>.</strong>     <hr>    <h2><a name="memchr">memchr</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  void *memchr( const void *buffer, int ch, size_t count );</pre>        </td>      </tr>    </table>    <p>The memchr() function looks for the first occurrence of <i>ch</i> within <i>count</i> characters in    the array pointed to by <i>buffer</i>. The return value points to the location of the first occurrence of    <i>ch</i>, or NULL if <i>ch</i> isn't found. For example:</p><pre>    char names[] = "Alan Bob Chris X Dave";    if( memchr(names,'X',strlen(names)) == NULL )      printf( "Didn't find an X\n" );    else      printf( "Found an X\n" );</pre>    <i>Related topics:</i><br>     <strong><a href="#memcpy">memcpy()</a> and <a href="#strstr">strstr()</a>.</strong>     <hr>    <h2><a name="memcmp">memcmp</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  int memcmp( const void *buffer1, const void *buffer2, size_t count );</pre>        </td>      </tr>    </table>    <p>The function memcmp() compares the first <i>count</i> characters of <i>buffer1</i> and <i>buffer2</i>.    The return values are as follows:</p>    <table bgcolor="#eeeeff">      <tr>        <td><strong>Value</strong></td>        <td><strong>Explanation</strong></td>      </tr>      <tr>        <td>less than 0</td>        <td>buffer1 is less than buffer2</td>      </tr>      <tr>        <td>equal to 0</td>        <td>buffer1 is equal to buffer2</td>      </tr>      <tr>        <td>greater than 0</td>        <td>buffer1 is greater than buffer2</td>      </tr>    </table>    <p><i>Related topics:</i><br>     <strong><a href="#memchr">memchr()</a>, <a href="#memcpy">memcpy()</a>, and <a href=    "#strcmp">strcmp()</a>.</strong></p>    <hr>    <h2><a name="memcpy">memcpy</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  void *memcpy( void *to, const void *from, size_t count );</pre>        </td>      </tr>    </table>    <p>The function memcpy() copies <i>count</i> characters from the array <i>from</i> to the array    <i>to</i>. memcpy() returns <i>to</i>. The behavior of memcpy() is undefined if <i>to</i> and <i>from</i>    overlap.</p>    <i>Related topics:</i><br>     <strong><a href="#memmove">memmove()</a>.</strong>     <hr>    <h2><a name="memmove">memmove</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  void *memmove( void *to, const void *from, size_t count );</pre>        </td>      </tr>    </table>    <p>The memmove() function is identical to <a href="#memcpy">memcpy()</a>, except that it works even if    <i>to</i> and <i>from</i> overlap.</p>    <i>Related topics:</i><br>     <strong><a href="#memcpy">memcpy()</a>.</strong>     <hr>    <h2><a name="memset">memset</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  void *memset( void *buffer, int ch, size_t count );</pre>        </td>      </tr>    </table>    <p>The function memset() copies <i>ch</i> into the first <i>count</i> characters of <i>buffer</i>, and    returns <i>buffer</i>. memset() is useful for intializing a section of memory to some value. For example,    this command:</p><pre>    memset( the_array, '\0', sizeof(the_array) );</pre>    <p>is a very efficient way to set all values of <i>the_array</i> to zero.</p>    <i>Related topics:</i><br>     <strong><a href="#memcmp">memcmp()</a>, <a href="#memcpy">memcpy()</a>, and <a href=    "#memmove">memmove()</a>.</strong>     <hr>    <h2><a name="strcat">strcat</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;string.h&gt;  char *strcat( char *str1, const char *str2 );</pre>        </td>      </tr>    </table>    <p>The strcat() function concatenates <i>str2</i> onto the end of <i>str1</i>, and returns <i>str1</i>.    For example:</p><pre>    printf( "Enter your name: " );    scanf( "%s", name );    title = strcat( name, " the Great" );

⌨️ 快捷键说明

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