I'm trying to write to a file and want to use Write System Call to make it faster. Basically I have a QVector and I want to store the results in a file. Originally I was just iterating through the array but it's too slow. So I did some research and found something called Write System Call, but I can't figure out how to set up the code.
This is what I have tried so far:
/*Header File*/
QVector<unsigned short> rawData;
/*Implementation File*/
int fd = open("output.txt", O_WRONLY)L
write(fd, &rawData, rawData.size());
close(fd);
While the above code does not crash on me it doesn't actually write anything to the output file. Any ideas what I'm doing wrong?
EDIT:
Using fwrite
I am able to write to the file but the data in the file is some strange Unicode. Basically it's not number which is what I'm trying to get. Here is what I'm doing:
FILE * pFile;
pfile = fopen("pixelValues.txt", "wb");
fwrite(&rawData, sizeof(unsigned short), sizeof(rawData), pFile);
fclose(pFile);