xref: /original-bsd/lib/libc/stdio/ungetc.3 (revision ec9268c1)
Copyright (c) 1990 The Regents of the University of California.
All rights reserved.

This code is derived from software contributed to Berkeley by
Chris Torek.

%sccs.include.redist.man%

@(#)ungetc.3 6.3 (Berkeley) 01/20/91

UNGETC 3 ""
C 7
NAME
ungetc - push character back into input stream
SYNOPSIS
#include <stdio.h>

int
ungetc(int c, FILE *stream);
.fr R
DESCRIPTION
Ungetc pushes the integer c (converted to an ``unsigned char'') back on an input stream, so that the next getc call on that stream will return c . Ungetc returns c .

One character of pushback is always guaranteed, but as long as there is sufficient memory, an effectively infinite amount of pushback is allowed. Attempts to push EOF are rejected.

A successful call to fseek erases all memory of pushed back characters.

"SEE ALSO"
getc(3), fseek(3), setvbuf(3)
"RETURN VALUE"
Ungetc returns EOF if it cannot push back the given character for any reason (this includes attempts to push EOF ).