ungetc() pushes characters back onto the input stream for binary
and text files.
ungetc() handles only single-byte characters. You
can use it to push back as many as four characters onto the
ungetc() buffer.
For every character pushed back with
ungetc(),
fflush() backs up the
file position by one character and clears all the pushed-back characters
from the stream. Backing up the file position may end up going across
a record boundary. Remember that for text files,
z/OS® XL C/C++ counts the
new-lines added to the records as single-byte characters when it calculates
the file position.
For example, given the stream you can run the following code fragment:
fgetc(fp); /* Returns A and puts the file position at */
/* the beginning of the character B */
ungetc('Z',fp); /* Logically inserts Z ahead of B */
fflush(fp); /* Moves the file position back by one to A, */
/* removes Z from the logical stream */
If you want fflush() to ignore ungetc() characters, you can set
the _EDC_COMPAT environment variable. See Using environment variables for more information.