bit by bit -> Binary File Reader
Good Day,
I have a binary field, that I need to read bit by bit
Is there a way to read in the actual binary values of a file.
I got this so far, but it reads per byte(quint8)
Code:
int fileSize = fileLoadBinary.size();
int i = 0;
quint8 tempVariable;
while(i < fileSize)
{
in >> tempVariable;
qDebug() << tempVariable;
strngLst.
append(QString(tempVariable
));
i++;
}
qDebug() << strngLst;
I want the actual binary values of the file(bit by bit)
Whats the way forward?
Help is much appreciated :)
Kind Regards
Re: bit by bit -> Binary File Reader
You can't read less than a byte each time.(at least, not to my knowledge)
But why would you need a bit by bit read?
I am sure the reason will turn out to be not valid.
Re: bit by bit -> Binary File Reader
No way forward. The smallest amount of data you can access is a byte. Reading bit by bit isn't possible. Make a "buffered input stream" that reads byte by byte then process the read data bit by bit.
Re: bit by bit -> Binary File Reader
QDataStream is not a general purpose binary stream, it is a serialization mechanism which expects additional data in the stream when reading from that stream. Use QFile::read() instead.