I'm using QString in Qt actually. So if there's a straightforward function please tell me:)
What I'm thinking of doing is storing a binary string into a file byte by byte:
QString code = "0110010101010100111010 /*...still lots of 0s & 1s here..*/";
ofstream out(/*...init the out file here...*/);
for(; code.length() / 8 > 0; code.remove(0, 8)) //a byte is 8 bits
{
BYTE b = QStringToByte(/*...the first 8 bits of the code left...*/);
out.write((char *)(&b), 1);
}
/*...deal with the rest less than 8 bits here...*/
How should I write my QStringToByte() function?
BYTE QStringToByte(QString s) //s is 8 bits
{
//?????
}
Thank you for your reply.
1s and0s as bits or bytes? Your thought process isn't clear here.