📄 ansistdio.html
字号:
resulting character is written.<dt><b>s</b><dd>The argument should be a pointer to an array of character type.Characters from the array are written up to (but not including)a terminating null character; if the precision is specified,no more than that many characters are written. If the precisionis not specified or is greater than the size of the array, thearray will contain a null character.<dt><b>p</b><dd>The argument should be a pointer to <b>void</b>. The value of the pointer is converted to a sequence of printable characters,in hexadecimal representation (prefixed with "0x").<dt><b>n</b><dd>The argument should be a pointer to an integer into whichthe number of characters written to the output streamso far by this call to <b><a href="./ansiStdio.html#fprintf">fprintf</a>( )</b> is written. No argument is converted.<dt><b>%</b><dd>A <b>%</b> is written. No argument is converted. The completeconversion specification is %%.</dl><p>If a conversion specification is invalid, the behavior is undefined.<p>If any argument is, or points to, a union or an aggregate (except for an array of character type using <b>s</b> conversion, or a pointer using <b>p</b> conversion), the behavior is undefined.<p>In no case does a non-existent or small field width cause truncation of afield if the result of a conversion is wider than the field width, thefield is expanded to contain the conversion result.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>stdio.h</b> <p></blockquote><h4>RETURNS</h4><blockquote><p><p>The number of characters written, or a negative value if anoutput error occurs.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ansiStdio.html#top">ansiStdio</a></b>, <b><a href="./fioLib.html#printf">printf</a>( )</b><hr><a name="fputc"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>fputc( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>fputc( )</strong> - write a character to a stream (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int fputc ( int c, /* character to write */ FILE * fp /* stream to write to */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine writes a character <i>c</i> to a specified stream, at theposition indicated by the stream's file position indicator(if defined), and advances the indicator appropriately.<p>If the file cannot support positioning requests, or if the stream was opened in append mode, the character is appended to the output stream.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>stdio.h</b> <p></blockquote><h4>RETURNS</h4><blockquote><p><p>The character written, or EOF if a write error occurs, with the errorindicator set for the stream.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ansiStdio.html#top">ansiStdio</a></b>, <b><a href="./ansiStdio.html#fputs">fputs</a>( )</b>, <b><a href="./ansiStdio.html#putc">putc</a>( )</b><hr><a name="fputs"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>fputs( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>fputs( )</strong> - write a string to a stream (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int fputs ( const char * s, /* string */ FILE * fp /* stream to write to */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine writes the string <i>s</i>, minus the terminating NULL character,to a specified stream. <p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>stdio.h</b> <p></blockquote><h4>RETURNS</h4><blockquote><p><p>A non-negative value, or EOF if a write error occurs.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ansiStdio.html#top">ansiStdio</a></b>, <b><a href="./ansiStdio.html#fputc">fputc</a>( )</b><hr><a name="fread"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>fread( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>fread( )</strong> - read data into an array (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int fread ( void * buf, /* where to copy data */ size_t size, /* element size */ size_t count, /* no. of elements */ FILE * fp /* stream to read from */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine reads, into the array <i>buf</i>, up to <i>count</i> elements of size<i>size</i>, from a specified stream <i>fp</i>. The file position indicator for thestream (if defined) is advanced by the number of characters successfullyread. If an error occurs, the resulting value of the file positionindicator for the stream is indeterminate. If a partial element is read,its value is indeterminate.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>stdio.h</b> <p></blockquote><h4>RETURNS</h4><blockquote><p><p>The number of elements successfully read, which may be less than <i>count</i>if a read error or end-of-file is encountered; or zero if <i>size</i> or<i>count</i> is zero, with the contents of the array and the state of thestream remaining unchanged.</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ansiStdio.html#top">ansiStdio</a></b><hr><a name="freopen"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>freopen( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>freopen( )</strong> - open a file specified by name (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>FILE * freopen ( const char * file, /* name of file */ const char * mode, /* mode */ FILE * fp /* stream */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine opens a file whose name is the string pointed to by <i>file</i>and associates it with a specified stream <i>fp</i>.The <i>mode</i> argument is used just as in the <b><a href="./ansiStdio.html#fopen">fopen</a>( )</b> function.<p>This routine first attempts to close any file that is associatedwith the specified stream. Failure to close the file successfully isignored. The error and end-of-file indicators for the stream are cleared.<p>Typically, <b><a href="./ansiStdio.html#freopen">freopen</a>( )</b> is used to attach the already-open streams<b>stdin</b>, <b>stdout</b>, and <b>stderr</b> to other files.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>stdio.h</b> <p></blockquote><h4>RETURNS</h4><blockquote><p><p>The value of <i>fp</i>, or a null pointer if the open operation fails.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ansiStdio.html#top">ansiStdio</a></b>, <b><a href="./ansiStdio.html#fopen">fopen</a>( )</b><hr><a name="fscanf"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>fscanf( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>fscanf( )</strong> - read and convert characters from a stream (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int fscanf ( FILE * fp, /* stream to read from */ char const * fmt, /* format string */ ... /* arguments to format string */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine reads characters from a specified stream, and interprets themaccording to format specifications in the string <i>fmt</i>, which specifiesthe admissible input sequences and how they are to be converted forassignment, using subsequent arguments as pointers to the objects toreceive the converted input.<p>If there are insufficient arguments for the format, the behavior isundefined. If the format is exhausted while arguments remain, the excessarguments are evaluated but are otherwise ignored.<p>The format is a multibyte character sequence, beginning and ending inits initial shift state. The format is composed of zero or more directives:one or more white-space characters; an ordinary multibyte character (neither<b>%</b> nor a white-space character); or a conversion specification. Eachconversion specification is introduced by the <b>%</b> character. After the <b>%</b>,the following appear in sequence:<p><ul><li>An optional assignment-suppressing character <b>*</b>.</li><li>An optional non-zero decimal integer that specifies the maximum field </li>width.<li>An optional <b>h</b> or <b>l</b> (el) indicating the size of the receiving </li>object. The conversion specifiers <b>d</b>, <b>i</b>, and <b>n</b> should be preceded by<b>h</b> if the corresponding argument is a pointer to <b>short int</b> ratherthan a pointer to <b>int</b>, or by <b>l</b> if it is a pointer to <b>long int</b>.Similarly, the conversion specifiers <b>o</b>, <b>u</b>, and <b>x</b> shall be precededby <b>h</b> if the corresponding argument is a pointer to <b>unsigned short int</b>rather than a pointer to <b>unsigned int</b>, or by <b>l</b> if it is a pointer to<b>unsigned long int</b>. Finally, the conversion specifiers <b>e</b>, <b>f</b>, and <b>g</b> shall be preceded by <b>l</b> if the corresponding argument is a pointer to<b>double</b> rather than a pointer to <b>float</b>. If an <b>h</b> or <b>l</b> appearswith any other conversion specifier, the behavior is undefined.<p></blockquote><h4>WARNING</h4><blockquote><p>ANSI C also specifies an optional <b>L</b> in some of the samecontexts as <b>l</b> above, corresponding to a <b>long double *</b> argument.However, the current release of the VxWorks libraries does not support <b>long double</b> data; using the optional <b>L</b> gives unpredictable results.<li>A character that specifies the type of conversion to be applied. The</li>valid conversion specifiers are described below.</ul><p>The <b><a href="./ansiStdio.html#fscanf">fscanf</a>( )</b> routine executes each directive of the format in turn. If a directive fails, as detailed below, <b><a href="./ansiStdio.html#fscanf">fscanf</a>( )</b> returns. Failuresare described as input failures (due to the unavailability of inputcharacters), or matching failures (due to inappropriate input).<p>A directive composed of white-space character(s) is executed by readinginput up to the first non-white-space character (which remains unread),or until no more characters can be read.<p>A directive that is an ordinary multibyte character is executed by readingthe next characters of the stream. If one of the characters differs fromone comprising the directive, the directive fails, and the differing andsubsequent characters remain unread.<p>A directive that is a conversion specification defines a set of matchinginput sequences, as described below for each specifier. A conversionspecification is executed in the following steps:<p>Input white-space characters (as specified by the <b><a href="./ansiCtype.html#isspace">isspace</a>( )</b> function) are skipped, unless the specification includes a <b>[</b>, <b>c</b>, or <b>n</b> specifier.<p>An input item is read from the stream, unless the specification includesan <b>n</b> specifier. An input item is defined as the longest matchingsequence of input characters, unless that exceeds a specified field width,in which case it is the initial subsequence of that length in thesequence. The first character, if any, after the input item remainsunread. If the length of the input item is zero, the execution of thedirective fails: this condition is a matching failure, unless an errorprevented input from the stream, in which case it is an input failure.<p>Except in the case of a <b>%</b> specifier, the input item is converted to atype appropriate to the conversion specifier. If the input item is not amatching sequence, the execution of the directive fails: this conditionis a matching failure. Unless assignment suppression was indicated by a<b>*</b>, the result of the conversion is placed in the object pointed to bythe first argument following the <i>fmt</i> argument that has not already
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -