Efficient Binary File IO
This section looks at the different basic techniques that can be used for manipulating binary files. The different techniques are discussed in separate sections. A Test Results subsection at the end of this section does an execution speed comparison of the techniques.
Using FILE Functions
The FILE functions can be used to read to and write from standard IO. These functions were already part of C but can still be used in C++. Table 12.3 shows the various FILE functions.
fopen | Open a file for reading/write of text/binary content |
fclose | Close an opened file |
fread | Read a block of data from an opened file |
fwrite | Write a block of data to an opened file |
fprintf | Print to an opened file (text) |
fscanf ... |
Get C++ Footprint and Performance Optimization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.