Which is faster? ifstreamor fread.
What should I use to read binary files?
fread()puts the entire file into memory.
Therefore, after freadaccess to the created buffer is fast.
Does the ifstream::open()entire file include memory?
or does he gain access to the hard drive every time we run ifstream::read()?
So ... does ifstream::open()== fread()?
or ( ifstream::open(); ifstream::read(file_length);) == fread()?
Or use ifstream::rdbuf()->read()?
edit
Now my readFile () method looks something like this:
void readFile()
{
std::ifstream fin;
fin.open("largefile.dat", ifstream::binary | ifstream::in);
readHeaderInfo(fin);
readPreference(fin);
readMainContent(fin);
readVolumeData(fin);
readTextureData(fin);
fin.close();
}
fin.read() ?
1 fin.read() ? , .
!