Guardian C Library Calls Reference Manual
ungetc
3-228 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
ungetc
The ungetc function pushes a single character back into an input file opened for
ANSI I/O.
character
specifies the character to be pushed back into the input stream.
stream
denotes a file opened for ANSI I/O.
Return Value
is character if the operation is successful, or the value EOF if an error occurs.
Usage Guidelines
•
The EOF value cannot be pushed back.
•
Only one character can be pushed back between read operations.
•
The fseek, fflush, and rewind functions nullify the effects of ungetc. If you call
ungetc and then call one of these routines, the next input call does not retrieve the
character pushed back by ungetc.
Example
In this example, the ungetc function pushes the character “a” back onto $a.b.c:
#include <stdioh>
FILE *fp;
int status;
int c;
fp = fopen("$a.b.c", "w");
/* ... */
c = 'a';
status = ungetc(c, fp);
#include <stdioh>
int ungetc(int character, FILE *stream);