📄 ansistdio.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/ansiStdio.html - generated by refgen from ansiStdio.c --> <title> ansiStdio </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>ansiStdio</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>ansiStdio</strong> - ANSI <b>stdio</b> documentation </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./ansiStdio.html#clearerr">clearerr</a>( )</b> - clear end-of-file and error flags for a stream (ANSI)<br><b><a href="./ansiStdio.html#fclose">fclose</a>( )</b> - close a stream (ANSI)<br><b><a href="./ansiStdio.html#fdopen">fdopen</a>( )</b> - open a file specified by a file descriptor (POSIX)<br><b><a href="./ansiStdio.html#feof">feof</a>( )</b> - test the end-of-file indicator for a stream (ANSI)<br><b><a href="./ansiStdio.html#ferror">ferror</a>( )</b> - test the error indicator for a file pointer (ANSI)<br><b><a href="./ansiStdio.html#fflush">fflush</a>( )</b> - flush a stream (ANSI)<br><b><a href="./ansiStdio.html#fgetc">fgetc</a>( )</b> - return the next character from a stream (ANSI)<br><b><a href="./ansiStdio.html#fgetpos">fgetpos</a>( )</b> - store the current value of the file position indicator for a stream (ANSI)<br><b><a href="./ansiStdio.html#fgets">fgets</a>( )</b> - read a specified number of characters from a stream (ANSI)<br><b><a href="./ansiStdio.html#fileno">fileno</a>( )</b> - return the file descriptor for a stream (POSIX)<br><b><a href="./ansiStdio.html#fopen">fopen</a>( )</b> - open a file specified by name (ANSI)<br><b><a href="./ansiStdio.html#fprintf">fprintf</a>( )</b> - write a formatted string to a stream (ANSI)<br><b><a href="./ansiStdio.html#fputc">fputc</a>( )</b> - write a character to a stream (ANSI)<br><b><a href="./ansiStdio.html#fputs">fputs</a>( )</b> - write a string to a stream (ANSI)<br><b><a href="./ansiStdio.html#fread">fread</a>( )</b> - read data into an array (ANSI)<br><b><a href="./ansiStdio.html#freopen">freopen</a>( )</b> - open a file specified by name (ANSI)<br><b><a href="./ansiStdio.html#fscanf">fscanf</a>( )</b> - read and convert characters from a stream (ANSI)<br><b><a href="./ansiStdio.html#fseek">fseek</a>( )</b> - set the file position indicator for a stream (ANSI)<br><b><a href="./ansiStdio.html#fsetpos">fsetpos</a>( )</b> - set the file position indicator for a stream (ANSI)<br><b><a href="./ansiStdio.html#ftell">ftell</a>( )</b> - return the current value of the file position indicator for a stream (ANSI)<br><b><a href="./ansiStdio.html#fwrite">fwrite</a>( )</b> - write from a specified array (ANSI)<br><b><a href="./ansiStdio.html#getc">getc</a>( )</b> - return the next character from a stream (ANSI)<br><b><a href="./ansiStdio.html#getchar">getchar</a>( )</b> - return the next character from the standard input stream (ANSI)<br><b><a href="./ansiStdio.html#gets">gets</a>( )</b> - read characters from the standard input stream (ANSI)<br><b><a href="./ansiStdio.html#getw">getw</a>( )</b> - read the next word (32-bit integer) from a stream<br><b><a href="./ansiStdio.html#perror">perror</a>( )</b> - map an error number in <b>errno</b> to an error message (ANSI)<br><b><a href="./ansiStdio.html#putc">putc</a>( )</b> - write a character to a stream (ANSI)<br><b><a href="./ansiStdio.html#putchar">putchar</a>( )</b> - write a character to the standard output stream (ANSI)<br><b><a href="./ansiStdio.html#puts">puts</a>( )</b> - write a string to the standard output stream (ANSI)<br><b><a href="./ansiStdio.html#putw">putw</a>( )</b> - write a word (32-bit integer) to a stream<br><b><a href="./ansiStdio.html#rewind">rewind</a>( )</b> - set the file position indicator to the beginning of a file (ANSI)<br><b><a href="./ansiStdio.html#scanf">scanf</a>( )</b> - read and convert characters from the standard input stream (ANSI)<br><b><a href="./ansiStdio.html#setbuf">setbuf</a>( )</b> - specify the buffering for a stream (ANSI)<br><b><a href="./ansiStdio.html#setbuffer">setbuffer</a>( )</b> - specify buffering for a stream<br><b><a href="./ansiStdio.html#setlinebuf">setlinebuf</a>( )</b> - set line buffering for standard output or standard error<br><b><a href="./ansiStdio.html#setvbuf">setvbuf</a>( )</b> - specify buffering for a stream (ANSI)<br><b><a href="./ansiStdio.html#stdioInit">stdioInit</a>( )</b> - initialize standard I/O support<br><b><a href="./ansiStdio.html#stdioFp">stdioFp</a>( )</b> - return the standard input/output/error FILE of the current task<br><b><a href="./ansiStdio.html#stdioShowInit">stdioShowInit</a>( )</b> - initialize the standard I/O show facility<br><b><a href="./ansiStdio.html#stdioShow">stdioShow</a>( )</b> - display file pointer internals<br><b><a href="./ansiStdio.html#tmpfile">tmpfile</a>( )</b> - create a temporary binary file (Unimplemented) (ANSI)<br><b><a href="./ansiStdio.html#tmpnam">tmpnam</a>( )</b> - generate a temporary file name (ANSI)<br><b><a href="./ansiStdio.html#ungetc">ungetc</a>( )</b> - push a character back into an input stream (ANSI)<br><b><a href="./ansiStdio.html#vfprintf">vfprintf</a>( )</b> - write a formatted string to a stream (ANSI)<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>The header <b>stdio.h</b> declares three types, several macros, and many functionsfor performing input and output.</blockQuote><h4>Types</h4><blockQuote>The types declared are <b>size_t</b> and:<dl><dt><b>FILE</b><dd>object type capable of recording all the information needed tocontrol a stream, including its file position indicator, a pointer to itsassociated buffer (if any), an error indicator that records whether aread/write error has occurred, and an end-of-file indicator that recordswhether the end of the file has been reached.<dt><b>fpos_t</b><dd>object type capable of recording all the information needed tospecify uniquely every position within a file. </dl></blockQuote><h4>Macros</h4><blockQuote>The macros are NULL and:<dl><dt><b>_IOFBF, _IOLBF, _IONBF</b><dd>expand to integral constant expressions with distinct values, suitablefor use as the third argument to <b><a href="./ansiStdio.html#setvbuf">setvbuf</a>( )</b>.<dt><b>BUFSIZ</b><dd>expands to an integral constant expression that is the size of thebuffer used by <b><a href="./ansiStdio.html#setbuf">setbuf</a>( )</b>.<dt><b>EOF</b><dd>expands to a negative integral constant expression that is returned byseveral functions to indicate <b>end-of-file</b>, that is, no more input from astream.<dt><b>FOPEN_MAX</b><dd>expands to an integral constant expression that is the minimum number ofthe files that the system guarantees can be open simultaneously.<dt><b>FILENAME_MAX</b><dd>expands to an integral constant expression that is the size needed for anarray of <b>char</b> large enough to hold the longest file name string thatcan be used.<dt><b>L_tmpnam</b><dd>expands to an integral constant expression that is the size needed foran array of <b>char</b> large enough to hold a temporary file name stringgenerated by <b><a href="./ansiStdio.html#tmpnam">tmpnam</a>( )</b>.<dt><b>SEEK_CUR, <b>SEEK_END</b>, SEEK_SET</b><dd>expand to integral constant expressions with distinct values suitablefor use as the third argument to <b><a href="./ansiStdio.html#fseek">fseek</a>( )</b>.<dt><b>TMP_MAX</b><dd>expands to an integral constant expression that is the minimum number offile names generated by <b><a href="./ansiStdio.html#tmpnam">tmpnam</a>( )</b> that will be unique.<dt><b>`stderr</b>, <b>stdin</b>, <b>stdout</b>'<dd>expressions of type "pointer to FILE" that point to the FILE objectsassociated, respectively, with the standard error, input, and output streams.<br> </dl></blockquote><h4>STREAMS</h4><blockquote><p>Input and output, whether to or from physical devices such as terminals andtape drives, or whether to or from files supported on structured storagedevices, are mapped into logical data streams, whose properties are moreuniform than their various inputs and outputs. Two forms of mapping aresupported: for text streams and for binary streams.<p>A text stream is an ordered sequence of characters composed into lines,each line consisting of zero or more characters plus a terminating new-linecharacter. Characters may have to be added, altered, or deletedon input and output to conform to differing conventions for representingtext in the host environment. Thus, there is no need for a one-to-onecorrespondence between the characters in a stream and those in the externalrepresentation. Data read in from a text stream will necessarily compareequal to the data that were earlier written out to that stream only if:the data consists only of printable characters and the control charactershorizontal tab and new-line; no new-line character is immediately precededby space characters; and the last character is a new-line character.Space characters are written out immediately before a new-line characterappears.<p>A binary stream is an ordered sequence of characters that can transparentlyrecord internal data. Data read in from a binary stream should compareequal to the data that was earlier written out to that stream, under thesame implementation. However, such a stream may have anumber of null characters appended to the end of the stream.</blockQuote><h4>Environmental Limits</h4><blockQuote>VxWorks supports text files with lines containing at least 254 characters,including the terminating new-line character. The value of the macroBUFSIZ is 1024.<p></blockquote><h4>FILES</h4><blockquote><p>A stream is associated with an external file (which may be a physicaldevice) by opening a file, which may involve creating a new file.Creating an existing file causes its former contents to be discarded, ifnecessary. If a file can support positioning requests (such as a diskfile, as opposed to a terminal), then a file position indicator associatedwith the stream is positioned at the start (character number zero) of thefile. The file position indicator is maintained by subsequent reads,writes, and positioning requests, to facilitate an orderly progressionthrough the file. All input takes place as if characters were read bysuccessive calls to <b><a href="./ansiStdio.html#fgetc">fgetc</a>( )</b>; all output takes place as if characters werewritten by successive calls to <b><a href="./ansiStdio.html#fputc">fputc</a>( )</b>.<p>Binary files are not truncated, except as defined in <b><a href="./ansiStdio.html#fopen">fopen</a>( )</b> documentation.<p>When a stream is unbuffered, characters are intended to appear from thesource or at the destination as soon as possible. Otherwise charactersmay be accumulated and transmitted to or from the host environment as ablock. When a stream is fully buffered, characters are intended to betransmitted to or from the host environment as a block when the buffer isfilled. When a stream is line buffered, characters are intended to betransmitted to or from the host environment as a block when a new-linecharacter is encountered. Furthermore, characters are intended to betransmitted as a block to the host environment when a buffer is filled,when input is requested on an unbuffered stream, or when input is requested ona line-buffered stream that requires the transmission of characters fromthe host environment. VxWorks supports these characteristics via the<b><a href="./ansiStdio.html#setbuf">setbuf</a>( )</b> and <b><a href="./ansiStdio.html#setvbuf">setvbuf</a>( )</b> functions.<p>A file may be disassociated from a controlling stream by closing the file.Output streams are flushed (any unwritten buffer contents are transmittedto the host environment) before the stream is disassociated from the file.The value of a pointer to a FILE object is indeterminate after the associatedfile is closed (including the standard text streams).<p>The file may be subsequently reopened, by the same or another programexecution, and its contents reclaimed or modified (if it can be repositionedat its start).<p></blockquote><h4>TASK TERMINATION</h4><blockquote><p>ANSI specifies that if the main function returns to its original caller orif <b><a href="./taskLib.html#exit">exit</a>( )</b> is called, all open files are closed (and hence all outputstreams are flushed) before program termination. This does <b>not</b>happen in VxWorks. The <b><a href="./taskLib.html#exit">exit</a>( )</b> function does not close all files openedfor that task. A file opened by one task may be used and closed by another.Unlike in UNIX, when a VxWorks task exits, it is the responsibility of thetask to <b><a href="./ansiStdio.html#fclose">fclose</a>( )</b> its file pointers, except <b>stdin</b>, <b>stdout</b>, and<b>stderr</b>. If a task is to be terminated asynchronously, use <b><a href="./sigLib.html#kill">kill</a>( )</b> andarrange for a signal handler to clean up.<p>The address of the FILE object used to control a stream may be significant;a copy of a FILE object may not necessarily serve in place of the original.<p>At program startup, three text streams are predefined and need not be openedexplicitly: standard input (for reading conventional input), standard output(for writing conventional output), and standard error (for writing diagnosticoutput). When opened, the standard error stream is not fully buffered; thestandard input and standard output streams are fully buffered if and only ifthe stream can be determined not to refer to an interactive device.<p>Functions that open additional (non-temporary) files require a file name,which is a string. VxWorks allows the same file to be open multiple timessimultaneously. It is up to the user to maintain synchronization betweendifferent tasks accessing the same file.<p></blockquote><h4>FIOLIB</h4><blockquote><p>Several routines normally considered part of standard I/O -- <b><a href="./fioLib.html#printf">printf</a>( )</b>,<b><a href="./fioLib.html#sprintf">sprintf</a>( )</b>, <b><a href="./fioLib.html#vprintf">vprintf</a>( )</b>, <b><a href="./fioLib.html#vsprintf">vsprintf</a>( )</b>, and <b><a href="./fioLib.html#sscanf">sscanf</a>( )</b> -- are not implemented as partof the buffered standard I/O library; they areinstead implemented in <b><a href="./fioLib.html#top">fioLib</a></b>. They do not use the standard I/O bufferingscheme. They are self-contained, formatted, but unbuffered I/Ofunctions. This allows a limited amount of formatted I/O to be achievedwithout the overhead of the standard I/O library.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><p><b><a href="./fioLib.html#top">fioLib</a></b>,<i>American National Standard for Information Systems - </i><i>Programming Language - C, ANSI X3.159-1989: Input/Output (<b>stdio.h</b>) </i><p><hr><a name="clearerr"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>clearerr( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>clearerr( )</strong> - clear end-of-file and error flags for a stream (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>void clearerr ( FILE * fp /* stream to clear EOF and ERROR flags for */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine clears the end-of-file and error flags for a specified stream.<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>stdio.h</b> <p></blockquote><h4>RETURNS</h4><blockquote><p>N/A<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./ansiStdio.html#top">ansiStdio</a></b>, <b><a href="./ansiStdio.html#feof">feof</a>( )</b>, <b><a href="./ansiStdio.html#ferror">ferror</a>( )</b><hr><a name="fclose"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries : Routines</i></a></p></blockquote><h1>fclose( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>fclose( )</strong> - close a stream (ANSI)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int fclose ( FILE * fp /* stream to close */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine flushes a specified stream and closes the associated file.Any unwritten buffered data is delivered to the host environment to be
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -