我实际上在 Qt 中使用 QString 。所以如果有一个简单的功能请告诉我:)
我正在考虑将二进制字符串逐字节存储到文件中:
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...*/
我应该如何编写我的 QStringToByte() 函数?
BYTE QStringToByte(QString s) //s is 8 bits
{
//?????
}
感谢你的回复。