Write NULL character to a file
Hello,
I have try to find the answer, but didn't have found one. I have a small problem to write NULL character to a file, the problem is that the character is not write.
Could somebody help me ?
I have tried with QDataStream but It's add many NULL char that I don't want.
Thanks.
This is the code that I use :
Code:
return;
QRgb* rgb = (QRgb*)image.scanLine(0);
for (int x = 0; x < image.width(); x++)
{
int AlphaValue = qAlpha(rgb[x]);
int RedValue = qRed(rgb[x]);
int GreenValue = qGreen(rgb[x]);
int BlueValue = qBlue(rgb[x]);
file.write(qPrintable(AlphaAscii));
//file.write((const char *)AlphaAscii.toAscii());
}
file.close();
Re: Write NULL character to a file
You can't write a null character using qPrintable because it terminates when \0 is encountered. Besides your code doesn't make any sense, you can cast between int and QChar.
Why don't you write the values directly?
Code:
for(...) {
file.write((const char*)(rgb+x), 4);
}
Re: Write NULL character to a file
Ok. Thanks you very much for your help !