Tools.h++ Manual
104011 Tandem Computers Incorporated 9-1
Using Class RWFile 9
Class 
RWFile 
encapsulates the standard C file operations for binary read and 
write, using the ANSI-C function 
fopen()
, 
fwrite()
, 
fread()
, etc. This 
class is patterned on class 
PFile 
of the Interviews Class Library (1987, Stanford 
University), but has been modified (and modernized) by Tools.h++ to use 
"
const
" modifiers. The member function names begin with upper case letters 
in order to maintain compatibility with class 
PFile
.
The constructor for class 
RWFile 
has prototype:
RWFile(const char* filename, const char* mode = 0);
This constructor will open a binary file called 
filename 
with mode 
mode 
(as 
defined by the Standard C function 
fopen()
; for example "
r+
"). If 
mode 
is 
zero (the default) then an existing file will be opened for update (mode “r+” 
for Unix, “rb+” for DOS), while non existing files will be created (modes “w+” 
and “wb+”). The destructor for this class closes the file.
There are member functions for flushing the file, and for testing whether the 
file is empty, has had an error, or is at the end-of-file










