unread_char (file, character)
A 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.
A 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); 65 Gamma> read_char(fr); 66 Gamma> unread_char(fr,'A'); t Gamma> read_char(fr); 65 Gamma> read_char(fr); 67 Gamma> read_char(fr); 68 Gamma>
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.