PDA

View Full Version : File Reading Advice



tntcoda
11th November 2008, 19:20
Hi,

I have a file with 400 bytes of data that i need to read in to a set of variables, the data is stored in the file exactly as it was in memory, so for example the first few bytes of the file are as follows:

2 bytes : unsigned short
255bytes : QByteArray
2 bytes : unsigned short
8 bytes: double
....

I need to read these bytes into variables of respective data types, and im a bit unsure how to do this.

Can anyone give me some pointers on how to approach this, i.e if i need to use text or data streams, or just QFile?

Thanks alot,

Jack

caduel
11th November 2008, 19:44
if you have written it with a QDataStream: read it using one.
otherwise, read it the way you wrote it. probably read some bytes into a char buffer, use reinterpret_cast and assign it to integers etc.