Hi everyone,
I would like to read a binary file as quickly as possible. Right now I am reading integer by integer, but that could end up being slow.. I imagine, it is probably best to put it all in a big buffer, but then I don't know how to convert that to an array of integers.
so far this is a snippet of the code I have:
Any help appreciated,Code:std::ifstream file("InvDat.dat", ios_base::in | ios_base::binary); char buf[BUF_SIZE]; //BUF_SIZE is 4 if(file.is_open()) { while (file.read(reinterpret_cast<char*>(&buf[0]), sizeof(uint32_t))) { uint32_t *num = reinterpret_cast<uint32_t* >(&buf[0]); std::cout << left << setw(10) << *num << " "; } std::cout << endl; } file.close();
Ted.



LinkBack URL
About LinkBacks


