74 lines
2.6 KiB
HTML
74 lines
2.6 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>getc(3)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>getc(3)</H1>
|
|
<HR>
|
|
<PRE>
|
|
|
|
</PRE>
|
|
<H2>NAME</H2><PRE>
|
|
getc, getchar, fgetc, getw - get character or word from stream
|
|
|
|
|
|
</PRE>
|
|
<H2>SYNOPSIS</H2><PRE>
|
|
<STRONG>#include</STRONG> <STRONG><stdio.h></STRONG>
|
|
|
|
<STRONG>int</STRONG> <STRONG>getc(FILE</STRONG> <STRONG>*</STRONG><EM>stream</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>getchar(void)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>fgetc(FILE</STRONG> <STRONG>*</STRONG><EM>stream</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>getw(FILE</STRONG> <STRONG>*</STRONG><EM>stream</EM><STRONG>)</STRONG>
|
|
|
|
|
|
</PRE>
|
|
<H2>DESCRIPTION</H2><PRE>
|
|
<STRONG>Getc</STRONG> returns the next character from the named input <EM>stream</EM>.
|
|
|
|
<STRONG>Getchar</STRONG>() is identical to <STRONG>getc</STRONG>(<STRONG>stdin</STRONG>).
|
|
|
|
<STRONG>Fgetc</STRONG> behaves like <STRONG>getc</STRONG>, but is a genuine function, not a macro; it may
|
|
be used to save object text.
|
|
|
|
<STRONG>Getw</STRONG> returns the next <STRONG>int</STRONG> from the named input <EM>stream</EM>. It returns the
|
|
constant <STRONG>EOF</STRONG> upon end of file or error, but since that is a good integer
|
|
value, <STRONG>feof</STRONG> and <STRONG><A HREF="../man3/ferror.3.html">ferror(3)</A></STRONG> should be used to check the success of <STRONG>getw</STRONG>.
|
|
<STRONG>Getw</STRONG> assumes no special alignment in the file.
|
|
|
|
|
|
</PRE>
|
|
<H2>SEE ALSO</H2><PRE>
|
|
<STRONG><A HREF="../man3/clearerr.3.html">clearerr(3)</A></STRONG>, <STRONG><A HREF="../man3/fopen.3.html">fopen(3)</A></STRONG>, <STRONG><A HREF="../man3/putc.3.html">putc(3)</A></STRONG>, <STRONG><A HREF="../man3/gets.3.html">gets(3)</A></STRONG>, <STRONG><A HREF="../man3/scanf.3.html">scanf(3)</A></STRONG>, <STRONG><A HREF="../man3/fread.3.html">fread(3)</A></STRONG>, <STRONG><A HREF="../man3/ungetc.3.html">ungetc(3)</A></STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>DIAGNOSTICS</H2><PRE>
|
|
These functions return the integer constant <STRONG>EOF</STRONG> at end of file, upon read
|
|
error, or if an attempt is made to read a file not opened by <STRONG>fopen</STRONG>. The
|
|
end-of-file condition is remembered, even on a terminal, and all
|
|
subsequent attempts to read will return <STRONG>EOF</STRONG> until the condition is
|
|
cleared with <STRONG><A HREF="../man3/clearerr.3.html">clearerr(3)</A></STRONG>.
|
|
|
|
|
|
</PRE>
|
|
<H2>BUGS</H2><PRE>
|
|
Because it is implemented as a macro, <STRONG>getc</STRONG> treats a <EM>stream</EM> argument with
|
|
side effects incorrectly. In particular, `getc(*f++);' doesn't work
|
|
sensibly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|