|
-
Sep 16th, 2001, 08:59 PM
#1
Fun Fun File I/O
Let DWORD fLen = 12, and BYTE pbuff = 0.
f is a valid file, opened in binary mode.
Code:
fwrite(&pbuff, 1, 1, f);
fwrite(&fLen, 4, 1, f);
fwrite(&pbuff, 1, 1, f);
Why does the output look like "00 0C 00", instead of "00 0C 00 00 00 00"?
Z.
-
Sep 18th, 2001, 07:24 AM
#2
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;
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 18th, 2001, 10:28 AM
#3
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.
-
Sep 18th, 2001, 10:54 AM
#4
Fanatic Member
Edit first post and change the title to "Fun Fun File I/O - Resolved"
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|