UNGETC(S) UNIX System V UNGETC(S)
Name
ungetc - push character back into input stream
Syntax
#include <stdio.h>
int ungetc (c, stream)
int c;
FILE *stream;
Description
The ungetc function inserts the character c into the buffer
associated with an input stream. That character, c, will be
returned by the next getc(S) call on that stream. The
ungetc function returns c, and leaves the file stream
unchanged.
One character of pushback is guaranteed, provided something
has already been read from the stream and the stream is
actually buffered.
If c equals EOF, ungetc does nothing to the buffer and
returns EOF.
The fseek(S) function erases all memory of inserted
characters.
See Also
fseek(S), getc(S), setbuf(S), stdio(S)
Diagnostics
ungetc returns EOF if it cannot insert the character.
Notes
When stream is stdin, one character may be pushed back onto
the buffer without a previous read statement.
Standards Conformance
ungetc is conformant with:
AT&T SVID Issue 2, Select Code 307-127;
The X/Open Portability Guide II of January 1987;
ANSI X3.159-198X C Language Draft Standard, May 13, 1988;
IEEE POSIX Std 1003.1-1988 with C Standard Language-
Dependent System Support;
and NIST FIPS 151-1.
(printed 6/20/89)