I am making a c++ qt program and I need to write data to a binary file. But there's a problem. When I do this, extra empty bytes are written to the file. Here is my code:
QDataStream output(&fileOut);
QBitArray result;
result.resize(8);
result.fill(true);
output << result;
As a result, my file consists of 5 bytes instead of 1:
00000000
00000000
00000000
00001000
11111111
Does anyone know how to solve this problem?

qt, but for standard C++, you have to use the stream'swritefunction to specify the exact number of bytes to write, and not use<<. This is especially the case if you're writing the file as "binary", where you need total control of how many bytes are written.