Accessing files
which files? (name of the files)
status? (opened, closed or shared)
operation? (read, write, append, insert)
- We use the C library functions fopen() to open files; fprintf(), fscanf(), fseek(), fsetpos(), fflusf() and rewind() to access them; and fclose() to close files.
- eg. a function call of the form fopen(filename, mode) opened the named file in a particular mode and returns a file pointer.
- different mode correspond to different operation e.g. "r" to open text file for reading; "w" to open text file for writing; "a" to open text file for appending; "rb" to open binary file for reading; "r+" to open text file for reading and writing