unread_char
unread_char — attempts to replace a character to a file for subsequent
reading.
unread_char (file, character)
fileA file pointer to a previously opened file. This may be either a file in the file system, or a string opened for read and write.
characterA single character.
This function attempts to place the given
character back onto the
file so that it can be read again by subsequent
calls to any of the read family of functions. Only one
character may be replaced onto a file between calls to
read. At least one read call
must have been made prior to calling this function.
An input file contains the following:
ABCDE
A call to unread_char within a succession of calls to
read_char will produce:
Gamma>fr = open("myunreadfile.dat", "r", t);#<File:"myunreadfile.dat">Gamma>read_char(fr);65Gamma>read_char(fr);66Gamma>unread_char(fr,'A');tGamma>read_char(fr);65Gamma>read_char(fr);67Gamma>read_char(fr);68Gamma>