Reading in 4 bytes at a time
- by alphomega
I have a big file full of integers that I'm loading in. I've just started using C++, and I'm trying out the filestream stuff. From everything I've read, it appears I can only read in bytes, So I've had to set up a char array, and then cast it as a int pointer.
Is there a way I can read in 4 bytes at a time, and eliminate the need for the char array?
const int HRSIZE = 129951336; //The size of the table
char bhr[HRSIZE]; //The table
int *dwhr;
int main()
{
ifstream fstr;
/* load the handranks.dat file */
std::cout << "Loading table.dat...\n";
fstr.open("table.dat");
fstr.read(bhr, HRSIZE);
fstr.close();
dwhr = (int *) bhr;
}