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

📄 stdio.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
exactly as if it were a change of active handle.(If the only action performed by one of the processes is one of the<i>exec</i>functions or<i><a href="_exit.html">_exit()</a></i>(not<i><a href="exit.html">exit()</a></i>),the handle is never accessed in that process.)<p>For the first handle, the first applicable condition below applies.After the actions required below are taken, if the handle is stillopen, the application can close it.<p><ul><p><li>If it is a file descriptor, no action is required.<p><li>If the only further action to be performed on any handle to this openfile descriptor is to close it, no action need be taken.<p><li>If it is a stream which is unbuffered, no action need be taken.<p><li>If it is a stream which is line buffered, and the lastbyte written to the stream was a newline (that is, as if a:<pre>putc('\n')</pre>was the most recent operation on that stream),no action need be taken.<p><li>If it is a stream which is open for writing or appending (but not also openfor reading), either an<i><a href="fflush.html">fflush()</a></i>must be done, or the stream must be closed.<p><li>If the stream is open for reading and it is at the end of the file (.Fn feofis true), no action need be taken.<p><li>If the stream is open with a mode that allows reading and the underlying openfile description refers to a device that is capable of seeking, eitheran<i><a href="fflush.html">fflush()</a></i>must occur or the stream must be closed.<p></ul><p>Otherwise, the result is undefined.<p>For the second handle:<ul><p><li>If any previous active handle has been used by a function that explicitlychanged the file offset, except as required above for the first handle,the application must perform an<i><a href="lseek.html">lseek()</a></i>or<i><a href="fseek.html">fseek()</a></i>(as appropriate to the type of handle)to an appropriate location.<p></ul><p>If the active handle ceases to be accessible before the requirementson the first handle, above, have been met, the state of the open filedescription becomes undefined.  This might occur during functions such as a<i><a href="fork.html">fork()</a></i>or<i><a href="_exit.html">_exit()</a></i>.<p>The<i>exec</i>functions make inaccessible all streamsthat are open at the time they are called, independent of which streamsor file descriptors may be available to the new process image.<p>When these rules are followed,regardless of the sequence of handles used,implementations will ensure that an application, even one consistingof several processes, will yield correct results:no data will be lost or duplicated when writing, andall data will be written in order, except as requested by seeks.It is implementation-dependent whether, and under what conditions,all input is seen exactly once.<p>If the rules above are not followed, the result is unspecified.<h4><a name = "tag_000_009_002">&nbsp;</a>Stream Orientation</h4><xref type="3" name="orientation"></xref>For conformance to the Multibyte Support Extension, the definition ofa stream is adjusted to include an<i>orientation</i>for both text and binary streams.  After a stream is associated withan external file, but before any operations are performed on it, thestream is without orientation.  Once a wide-character input/outputfunction has been applied to a stream without orientation, the streambecomes<i>wide-orientated</i>.Similarly, once a byte input/output function has been applied to astream without orientation, the stream becomes<i>byte-orientated</i>.Only a call to the<i><a href="freopen.html">freopen()</a></i>function or the<i><a href="fwide.html">fwide()</a></i>function can otherwise alter the orientation of a stream.<p>A successful call to<i><a href="freopen.html">freopen()</a></i>removes any orientation.  The three predefined streams<i>standard input</i>,<i>standard output</i>and<i>standard error</i>are unorientated at program startup.<p>Byte input/output functions cannot be applied to a wide-orientatedstream, and wide-character input/output functions cannot be applied toa byte-orientated stream.  The remaining stream operations do notaffect and are not affected by a stream's orientation, except for thefollowing additional restrictions:<ul><p><li>Binary wide-orientated streams have the file positioning restrictionsascribed to both text and binary streams.<p><li>For wide-orientated streams, after a successful call to afile-positioning function that leaves the file position indicatorprior to the end-of-file, a wide-character output function canoverwrite a partial character; any file contents beyond thebyte(s) written are henceforth undefined.<p></ul><p>Each wide-orientated stream has an associated<b>mbstate_t</b>object that stores the current parse state of the stream.  Asuccessful call to<i><a href="fgetpos.html">fgetpos()</a></i>stores a representation of the value of this<b>mbstate_t</b>object as part of the value of the<b>fpos_t</b>object.  A later successful call to<i><a href="fsetpos.html">fsetpos()</a></i>using the same stored<b>fpos_t</b>value restores the value of the associated<b>mbstate_t</b>object as well as the position within the controlled stream.<p>Although both text and binary wide-orientated streams are conceptuallysequences of wide-characters, the external file associated with awide-orientated stream is a sequence of (possibly multibyte)charactersgeneralised as follows:<ul><p><li>Multibyte encodings within files may contain embedded null bytes(unlike multibyte encodings valid for use internal to the program).<p><li>A file need not begin nor end in the initial shift state.<p></ul><p>Moreover, the encodings used for characters may differ amongfiles.  Both the nature and choice of such encodings areimplementation-dependent.<p>The wide-character input functions read characters from thestream and convert them to wide-characters as if they were read bysuccessive calls to the<i><a href="fgetwc.html">fgetwc()</a></i>function.  Each conversion occurs as if by a call to the<i><a href="mbrtowc.html">mbrtowc()</a></i>function, with the conversion state described by the stream's own<b>mbstate_t</b>object.<p>The wide-character output functions convert wide-charactersto (possibly multibyte) characters and write them to the stream asif they were written by successive calls to the<i><a href="fputwc.html">fputwc()</a></i>function.  Each conversion occurs as if by a call to the<i><a href="wcrtomb.html">wcrtomb()</a></i>function, with the conversion state described by the stream's own<b>mbstate_t</b>object.<p>An <i>encoding&nbsp;error</i> occurs if the character sequence presented tothe underlying<i><a href="mbrtowc.html">mbrtowc()</a></i>function does not form a valid (generalised) character, orif the code value passed to the underlying<i><a href="wcrtomb.html">wcrtomb()</a></i>function does not correspond to a valid (generalised)character.  The wide-character input/output functions and the byteinput/output functions store the value of the macro EILSEQ in<i>errno</i>if and only if an encoding error occurs.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

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