📄 fgetc.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>fgetc</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_041"> </a>NAME</h4><blockquote>fgetc - get a byte from a stream</blockquote><h4><a name = "tag_000_005_042"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="stdio.h.html">stdio.h</a>>int fgetc(FILE *<i>stream</i>);</code></pre></blockquote><h4><a name = "tag_000_005_043"> </a>DESCRIPTION</h4><blockquote>The<i>fgetc()</i>function obtains the next byte (if present) as an<b>unsigned char</b>converted to an<b>int</b>,from the input stream pointed to by<i>stream</i>,and advances the associated file position indicator for thestream (if defined).<p>The<i>fgetc()</i>function may mark the<i>st_atime</i>field of the file associated with<i>stream</i>for update.The<i>st_atime</i>field will be marked for update by the first successfulexecution of<i>fgetc()</i>,<i><a href="fgets.html">fgets()</a></i>,<i><a href="fgetwc.html">fgetwc()</a></i>,<i><a href="fgetws.html">fgetws()</a></i>,<i><a href="fread.html">fread()</a></i>,<i><a href="fscanf.html">fscanf()</a></i>,<i><a href="getc.html">getc()</a></i>,<i><a href="getchar.html">getchar()</a></i>,<i><a href="gets.html">gets()</a></i>or<i><a href="scanf.html">scanf()</a></i>using<i>stream</i>that returns data not supplied by a prior call to<i><a href="ungetc.html">ungetc()</a></i>or<i><a href="ungetwc.html">ungetwc()</a></i>.</blockquote><h4><a name = "tag_000_005_044"> </a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>fgetc()</i>returns the next byte from the input stream pointed to by<i>stream</i>.If the stream is at end-of-file, the end-of-file indicator forthe stream is set and<i>fgetc()</i>returns EOF.If a read error occurs, the error indicator for the stream is set,<i>fgetc()</i>returns EOF and sets<i>errno</i>to indicate the error.</blockquote><h4><a name = "tag_000_005_045"> </a>ERRORS</h4><blockquote>The<i>fgetc()</i>function will fail if data needs to be read and:<dl compact><dt>[EAGAIN]<dd>The O_NONBLOCK flag is set for the file descriptor underlying<i>stream</i>and the process would be delayed in the<i>fgetc()</i>operation.<dt>[EBADF]<dd>The file descriptor underlying<i>stream</i>is not a valid file descriptor open for reading.<dt>[EINTR]<dd>The read operation was terminated due to the receiptof a signal, and no data was transferred.<dt>[EIO]<dd>A physical I/O error has occurred, orthe process is in a background process group attempting to readfrom its controlling terminal, and either the process is ignoring orblocking the SIGTTIN signal or the process group is orphaned.This error may also be generated for implementation-dependent reasons.<dt>[EOVERFLOW]<dd>The file is a regular file and an attempt was made to read at or beyondthe offset maximum associated with the corresponding stream.</dl><p>The<i>fgetc()</i>function may fail if:<dl compact><dt>[ENOMEM]<dd>Insufficient storage space is available.<dt>[ENXIO]<dd>A request was made of a non-existent device, or the request wasoutside the capabilities of the device.</dl><br></blockquote><h4><a name = "tag_000_005_046"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_047"> </a>APPLICATION USAGE</h4><blockquote>If the integer value returned by<i>fgetc()</i>is stored into a variable of type<b>char</b>and then compared againstthe integer constant EOF, the comparison may never succeed,because sign-extension of a variable of type<b>char</b>on widening to integer isimplementation-dependent.<p>The<i><a href="ferror.html">ferror()</a></i>or<i><a href="feof.html">feof()</a></i>functions must be used to distinguish betweenan error condition and an end-of-file condition.</blockquote><h4><a name = "tag_000_005_048"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_049"> </a>SEE ALSO</h4><blockquote><i><a href="feof.html">feof()</a></i>,<i><a href="ferror.html">ferror()</a></i>,<i><a href="fopen.html">fopen()</a></i>,<i><a href="getchar.html">getchar()</a></i>,<i><a href="getc.html">getc()</a></i>,<i><a href="stdio.h.html"><stdio.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 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 + -