Let DWORD fLen = 12, and BYTE pbuff = 0.
f is a valid file, opened in binary mode.
Why does the output look like "00 0C 00", instead of "00 0C 00 00 00 00"?Code:fwrite(&pbuff, 1, 1, f);
fwrite(&fLen, 4, 1, f);
fwrite(&pbuff, 1, 1, f);
Z.
Printable View
Let DWORD fLen = 12, and BYTE pbuff = 0.
f is a valid file, opened in binary mode.
Why does the output look like "00 0C 00", instead of "00 0C 00 00 00 00"?Code:fwrite(&pbuff, 1, 1, f);
fwrite(&fLen, 4, 1, f);
fwrite(&pbuff, 1, 1, f);
Z.
seems to be some error, it works for me...
Code:#include <stdio.h>
int main(int argc, char* argv[])
{
FILE* file;
unsigned long ulSome = 12;
unsigned char ucSome = 0;
file = fopen("testfile.dat", "wb");
fwrite(&ucSome, 1, 1, file);
fwrite(&ulSome, 4, 1, file);
fwrite(&ucSome, 1, 1, file);
fclose(file);
return 0;
}
Yeah, it was a me-being-stupid kinda error =). I was writing out all four bytes, but over writing 3 of them. I fixed it last night. Thanks though!
Z.
Edit first post and change the title to "Fun Fun File I/O - Resolved"
thanks :)