UNGETC(3S) — STANDARD I/O FUNCTIONS
NAME
ungetc − push character back into input stream
SYNOPSIS
#include <stdio.h>
ungetc(c, stream)
FILE ∗stream;
DESCRIPTION
ungetc() pushes the character c back onto an input stream. That character will be returned by the next getc() call on that stream. ungetc() returns c, and leaves the file stream unchanged.
One character of pushback is guaranteed provided something has been read from the stream and the stream is actually buffered. In the case that stream is stdin, one character may be pushed back onto the buffer without a previous read statement.
If c equals EOF, ungetc() does nothing to the buffer and returns EOF.
An fseek(3S) erases all memory of pushed back characters.
SEE ALSO
fseek(3S), getc(3V), setbuf(3V)
DIAGNOSTICS
ungetc() returns EOF if it cannot push a character back.
Sun Release 4.1 — Last change: 18 November 1987