PDA

View Full Version : Re: Reading binary files using readAll problem [SOLVED]



Miss Engineer
18th September 2014, 15:57
I thought everything was going fine until I compared the data I wrote into the binary file with the data I am reading, everything is the same except 6 bytes which are missing during reading!!


file.write(towrite);
qDebug()<<towrite.toHex();


QByteArray data;
data=file.readAll();
qDebug()<<data.toHex();


the first piece of code gives:
"400000931bad9c77bfbfbfbfb5eb75dfdfdfdfea40c8701010 101debebf80808080fc10ecc0c0c0c0ea76a8e060606051536 67050505051ca2cb82828282055c33c1c1c1c19faa0b60e0e0 e0c8b373309090908c1a9e7858585854a603dc2c2c2c2f717b 461a1a1a19d64db70d0d0d0c67e81b87878787e60539c3c3c3 c3883988e2222222342856b11111110c7226589898989f6a8e 907b7d"

while the second gives:
"400000931bad9c77bfbfbfbfb5eb75dfdfdfdfea40c8701010 101debebf80808080fc10ecc0c0c0c0ea76a8e060606051536 67050505051ca2cb82828282055c33c1c1c1c19faa0b60e0e0 e0c8b373309090908c1a9e7858585854a603dc2c2c2c2f717b 461a1a1a19d64db70c67e81b87878787e60539c3c3c3c38839 88e2222222342856b11111110c7226589898989f6a8e907b7d"

Please help!
I checked the binary file using a hex editor and the writing process was successful, nothing is missing.

Added after 17 minutes:

Just figured out the problem.. I was reading it as a text file. SOLVED!