Archived

This topic is now archived and is closed to further replies.

Chocoboko

A bit of trouble with fread

Recommended Posts

Hello, I am having a bit of trouble with fread. It is only reading one character out of a file when I am trying to get it to read 5. fread does return 5, but I still only get one character. Here is my code: char test[5]; fp=fopen("wa.txt", "rb"); fread(test,1,5,fp); MessageBox(wmain,test,"Test",MB_OK); fclose(fp); The messagebox command only pops up a single character, which is the first character in my file. Would you happen to know what I might be doing wrong? Thank you.

Share this post


Link to post
Share on other sites
you are opening binary when it says ''wa.txt'', not sure if it matters, but try it without the ''b'' in "rb". you may have to use getch or something like that instead of fread in text mode

Share this post


Link to post
Share on other sites