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

📄 stdio_details.html

📁 ssd5 数据结构的课件
💻 HTML
📖 第 1 页 / 共 3 页
字号:
    }    fclose( input );    fclose( output );</pre>    <p>generates a copy of the file tmp.c called tmpCopy.c.</p>    <i>Related topics:</i><br>     <strong><a href="#fgetc">fgetc()</a>, <a href="#fputc">fputc()</a>, <a href="#getchar">getchar()</a>,     <a href="#putchar">putchar()</a></strong>     <hr>    <h2><a name="putchar">putchar</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int putchar( int ch );</pre>        </td>      </tr>    </table>    <p>The putchar() function writes <i>ch</i> to <strong>STDOUT</strong>. The code</p><pre>    putchar( ch );</pre>    <p>is the same as</p><pre>    putc( ch, STDOUT );</pre>    <p>The return value of putchar() is the written character, or EOF if there is an error.</p>    <i>Related topics:</i><br>     <strong><a href="#putc">putc()</a></strong>     <hr>    <h2><a name="puts">puts</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int puts( char *str );</pre>        </td>      </tr>    </table>    <p>The function puts() writes <i>str</i> to <strong>STDOUT</strong>. puts() returns non-negative on    success, or EOF on failure.</p>    <i>Related topics:</i><br>     <strong><a href="#putc">putc()</a>, <a href="#gets">gets()</a>,      <a href="#printf">printf()</a></strong>     <hr>    <h2><a name="remove">remove</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int remove( const char *fname );</pre>        </td>      </tr>    </table>    <p>The remove() function erases the file specified by <i>fname</i>. The return value of remove() is zero    upon success, and non-zero if there is an error.</p>    <i>Related topics:</i><br>     <strong><a href="#rename">rename()</a></strong>     <hr>    <h2><a name="rename">rename</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int rename( const char *oldfname, const char *newfname );</pre>        </td>      </tr>    </table>    <p>The function rename() changes the name of the file <i>oldfname</i> to <i>newfname</i>. The return    value of rename() is zero upon success, non-zero on error.</p>    <i>Related topics:</i><br>     <strong><a href="#remove">remove()</a></strong>     <hr>    <h2><a name="rewind">rewind</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  void rewind( FILE *stream );</pre>        </td>      </tr>    </table>    <p>The function rewind() moves the file position indicator to the beginning of the specified    <i>stream</i>, also clearing the error and EOF flags associated with that stream.</p>    <i>Related topics:</i><br>     <strong><a href="#fseek">fseek()</a></strong>     <hr>    <h2><a name="scanf">scanf</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int scanf( const char *format, ... );</pre>        </td>      </tr>    </table>    <p>The scanf() function reads input from <strong>stdin</strong>, according to the given <i>format</i>,    and stores the data in the other arguments. It works a lot like <a href="#printf">printf()</a>. The    <i>format</i> string consists of control characters, whitespace characters, and non-whitespace    characters. The control characters are preceded by a % sign, and are as follows:</p>    <table bgcolor="#eeeeff">      <tr>        <td><strong>Control Character</strong></td>        <td><strong>Explanation</strong></td>      </tr>      <tr>        <td>%c</td>        <td>a single character</td>      </tr>      <tr>        <td>%d</td>        <td>a decimal integer</td>      </tr>      <tr>        <td>%i</td>        <td>an integer</td>      </tr>      <tr>        <td>%e, %f, %g</td>        <td>a floating-point number</td>      </tr>      <tr>        <td>%o</td>        <td>an octal number</td>      </tr>      <tr>        <td>%s</td>        <td>a string</td>      </tr>      <tr>        <td>%x</td>        <td>a hexadecimal number</td>      </tr>      <tr>        <td>%p</td>        <td>a pointer</td>      </tr>      <tr>        <td>%n</td>        <td>an integer equal to the number of characters read so far</td>      </tr>      <tr>        <td>%u</td>        <td>an unsigned integer</td>      </tr>      <tr>        <td>%[]</td>        <td>a set of characters</td>      </tr>      <tr>        <td>%%</td>        <td>a percent sign</td>      </tr>    </table>    <p>scanf() reads the input, matching the characters from <i>format</i>. When a control character is read,    it puts the value in the next variable. Whitespace (tabs, spaces, etc) are skipped. Non-whitespace    characters are matched to the input, then discarded. If a number comes between the % sign and the control    character, then only that many characters will be converted into the variable. If scanf() encounters a    set of characters, denoted by the %[] control character, then any characters found within the brackets    are read into the variable. The return value of scanf() is the number of variables that were successfully    assigned values, or EOF if there is an error.</p>    <i>Related topics:</i><br>     <strong><a href="#printf">printf()</a> and <a href="#fscanf">fscanf()</a>.</strong>     <hr>    <h2><a name="setbuf">setbuf</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  void setbuf( FILE *stream, char *buffer );</pre>        </td>      </tr>    </table>    <p>The setbuf() function sets <i>stream</i> to use <i>buffer</i>, or, if <i>buffer</i> is null, turns off    buffering. If a non-standard buffer size is used, it should by <strong>BUFSIZ</strong> characters    long.</p>    <i>Related topics:</i><br>    <strong><a href="#fopen">fopen()</a>, <a href="#fclose">fclose()</a>, <a href=    "#setvbuf">setvbuf()</a>,</strong>     <hr>    <h2><a name="setvbuf">setvbuf</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int setvbuf( FILE *stream, char *buffer, int mode, size_t size );</pre>        </td>      </tr>    </table>    <p>The function setvbuf() sets the buffer for <i>stream</i> to be <i>buffer</i>, with a size of    <i>size</i>. <i>mode</i> can be:</p>    <ul>      <li>_IOFBF, which indicates full buffering</li>      <li>_IOLBF, which means line buffering</li>      <li>_IONBF, which means no buffering</li>    </ul>    <br>    <br>     <i>Related topics:</i><br>    <strong><a href="#setbuf">setbuf()</a>,</strong>     <hr>    <h2><a name="sprintf">sprintf</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int sprintf( char *buffer, const char *format, ... );</pre>        </td>      </tr>    </table>    <p>The sprintf() function is just like <a href="#printf">printf()</a>, except that the output is sent to    <i>buffer</i>. The return value is the number of characters written. For example:</p><pre>    char string[50];    int file_number = 0;        sprintf( string, "file.%d", file_number );    file_number++;    output_file = fopen( string, "w" );</pre>    <i>Related topics:</i><br>    <strong><a href="#printf">printf()</a>, <a href="#fsprintf">fsprintf()</a>,</strong>     <hr>    <h2><a name="sscanf">sscanf</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int sscanf( const char *buffer, const char *format, ... );</pre>        </td>      </tr>    </table>    <p>The function sscanf() is just like <a href="#scanf">scanf()</a>, except that the input is read from    <i>buffer</i>.</p>    <i>Related topics:</i><br>    <strong><a href="#scanf">scanf()</a>, <a href="#fscanf">fscanf()</a>,</strong>     <hr>    <h2><a name="tmpfile">tmpfile</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  FILE *tmpfile( void );</pre>        </td>      </tr>    </table>    <p>The function tempfile() opens a temporary file with an unique filename and returns a pointer to that    file. If there is an error, null is returned.</p>    <i>Related topics:</i><br>    <strong><a href="#tmpnam">tmpnam()</a>,</strong>     <hr>    <h2><a name="tmpnam">tmpnam</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  char *tmpnam( char *name );</pre>        </td>      </tr>    </table>    <p>The tmpnam() function creates an unique filename and stores it in <i>name</i>. tmpnam() can be called    up to <strong>TMP_MAX</strong> times.</p>    <i>Related topics:</i><br>    <strong><a href="#tmpfile">tmpfile()</a>,</strong>     <hr>    <h2><a name="ungetc">ungetc</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdio.h&gt;  int ungetc( int ch, FILE *stream );</pre>        </td>      </tr>    </table>    <p>The function ungetc() puts the character <i>ch</i> back in <i>stream</i>.</p>    <i>Related topics:</i><br>    <strong><a href="#getc">getc()</a>,</strong>     <hr>    <h2><a name="vprintf">vprintf, vfprintf, and vsprintf</a></h2>    <i>Syntax:</i>     <table bgcolor="#ccccff">      <tr>        <td><pre>  #include &lt;stdarg.h&gt;  #include &lt;stdio.h&gt;  int vprintf( char *format, va_list arg_ptr );  int vfprintf( FILE *stream, const char *format, va_list arg_ptr );  int vsprintf( char *buffer, char *format, va_list arg_ptr );</pre>        </td>      </tr>    </table>    <p>These functions are very much like <a href="#printf">printf()</a>, <a href="#fprintf">fprintf()</a>,    and <a href="#sprintf">sprintf()</a>. The difference is that the argument list is a pointer to a list of    arguments. <strong>va_list</strong> is defined in STDARG.H, and is also used by <a href=    "stdother_details.html#va_arg">va_arg()</a>. For example:</p><pre>    void error( char *fmt, ... ) {      va_list args;            va_start( args, fmt );      fprintf( stderr, "Error: " );      vfprintf( stderr, fmt, args );      fprintf( stderr, "\n" );      va_end( args );      exit( 1 );    }</pre>  </body></html>

⌨️ 快捷键说明

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