In last hour's lesson you learned the basics of reading and writing disk data files. In this lesson you'll learn more about communication with disk data files. The main topics discussed in this hour are
Random access to files
Reading or writing binary data
Redirecting the standard streams
In addition, the following C I/O functions are introduced in this lesson:
The fseek(), ftell(), and rewind() functions
The fscanf() and fprintf() functions
The freopen() function
Summary
- The file position indicator can be reset by the fseek() function.
- The ftell() function can tell you the value of the current file position indicator.
- The rewind() function can set the file position indicator to the beginning of a file.
- After you specify the mode of the fopen() function for the binary file, you can use the fread() or fwrite() functions to perform I/O operations on binary data.
- Besides the fact that the fscanf() and fprintf() functions can do the same jobs as the scanf() and printf() functions, the fscanf() and fprintf() functions also allow the programmer to specify I/O streams.
- You can redirect the standard streams, such as stdin and stdout, to a disk file with the help of the freopen() function.
- 50 views