I would like to read a large file that has a structure similar to the following:
John 10 department
Hello 14 kjezlkjzlkj
jhfekh 144 lkjzlkjrzlj
........
The problem is I want to minimize the number of I/O access to the disk while reading this file in C++. Is there a way to access the file on Disk, then read a large portion of the file to memory ( that 1 disk access), then read a second large portion of the file ( 2nd disk access…Etc)?
Any help will be appreciated.
Just create a large buffer and fill it up with one read. Repeat if necessary.
The streams (stdio) implements this. You can use
fopenand then use setbufferEDIT
It is rather simple
Then use any of the operations to read
fscanf,fgetsetc.EDIT
Sorry did not notice it was C++
Here is the code for C++
Then can use
int i; is >> ietc
Happy now Tino Didriksen