Skip to main content
GameDev.net gamedev.net
🔒 Locked

fwrite Doesn't Write

Started by PyroBoy Jan 16, 2002 at 4:35 PM 3 replies 3.2k views
Original Post
PyroBoy
PyroBoy
I''m having trouble with fwrite not writing anything. Observe: //Open file FILE *filePoint = fopen("test.dat", "wb"); if (filePoint == NULL) return false; //Write int data = 5; if (fwrite(&data, sizeof(int), 1, filePoint) != 1) return false; //Close File fclose(filePoint); This is inside another function, by the way, hence the returns on the error checking. filePoint is non null on the fopen, so according to the docs the file opens properly. fwrite returns 1, so according to the docs that means 1 item was written to the file. The problem is, the file it writes to is empty after this code runs (and yes, I''m sure it''s getting run in the first place. I debugged through it). What the hell is going on???
jenova
jenova
when you say "empty". do you mean you open it up with "edit" and see nothing. or check the file size and it is "0".

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
PyroBoy
PyroBoy
...it just started working. I didn''t do *anything* to it. Didn''t change a single line.

Fuck, I hate bugs like that.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.