UNGETC(3S)
NAME
ungetc − push character back into input stream
SYNOPSIS
#include <stdio.h>
int ungetc (c, stream)
int c;
FILE ∗stream;
DESCRIPTION
Ungetc inserts the character c (converted to an unsigned char) into the buffer associated with an input stream. That character, c, will be returned by the next getc(3S) call on that stream. A successful intervening call to a file positioning function with stream (fseek, fsetpos, or rewind) erases all memory of the inserted characters.
Ungetc affects only the buffer associated with the input stream. It does not affect the contents of the file corresponding to stream.
One character of pushback is guaranteed.
If c equals EOF, ungetc does nothing to the buffer and returns EOF.
RETURN VALUE
If successful, ungetc returns c and clears the end-of-file indicator for the stream. Ungetc returns EOF if it cannot insert the character.
SEE ALSO
fseek(3S), fsetpos(3S), getc(3S), setbuf(3S).
STANDARDS CONFORMANCE
ungetc: SVID2, XPG2, XPG3, POSIX.1, FIPS 151-1, ANSI C
Hewlett-Packard Company — HP-UX Release 7.0: Sept 1989