Section (3) fgetc
fgetc, fgets, getc, getchar, ungetc — input of characters and strings
fgetc() reads the next
and returns it as an unsigned char
cast to an int, or
EOF on end of file or error.
getc() is equivalent to
fgetc() except that it may be
implemented as a macro which evaluates
stream more than once.
getchar() is equivalent to
fgets() reads in at most one
stream and stores them into the
buffer pointed to by
s. Reading stops after an
EOF or a newline. If a newline
is read, it is stored into the buffer. A terminating null
byte (_zsingle_quotesz_ _zsingle_quotesz_) is stored after the last character in the
c back to
stream, cast to unsigned char, where it is available for
subsequent read operations. Pushed-back characters will be
returned in reverse order; only one pushback is
Calls to the functions described here can be mixed with
each other and with calls to other input functions from the
stdio library for the same
For nonlocking counterparts, see unlocked_stdio(3).
getchar() return the character read as an
unsigned char cast to an
EOF on end of file or error.
s on success, and NULL on error
or when end of file occurs while no characters have been
c on success, or
EOF on error.
For an explanation of the terms used in this section, see attributes(7).
POSIX.1-2001, POSIX.1-2008, C89, C99.
It is not advisable to mix calls to input functions from
stdio library with
low-level calls to read(2) for the file
descriptor associated with the input stream; the results will
be undefined and very probably not what you want.
This page is part of release 4.16 of the Linux
man-pages project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
Copyright (c) 1993 by Thomas Koenig (ig25rz.uni-karlsruhe.de)
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date. The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein. The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.
Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faithcs.unc.edu)
Modified Fri Sep 8 15:48:13 1995 by Andries Brouwer (aebcwi.nl)