Archived

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

Code Mole

fread stops reading???

Recommended Posts

I''m using fread to read in a file, the size of the file is something like 3,276 bytes but my code breaks down after 889 bytes read in and I checked it out in the debugger and fread stops working, it will not read in anymore. I looked around in the code and my FILE * fp->cnt = 0 (its 889 when i open the file, and each read subtracts from it) and in the code for fread, it will loop as long as cnt != 0. so does anyone know if there is a limit on fread (like a max buffer size) or if something that I did wrong that would cause this. I''m pretty confused on this one. the file i''m reading from is big endian, could that be the problem and fread is reading it as little endian? ~code mole~

Share this post


Link to post
Share on other sites
well basically all my code is a loop reading in data using fread, there is alot of code so i just dont'' want to dump it here.

since i''ve saved things to file, I know my code works. Its reading things in and saving it. Since the data i''m reading in is very repeditive, all my code is in a while loop, till i reach the end of file, but that doesn''t happen since fread stops reading after like 900 bytes. (i''ve checked it out in the debugger, the cnt variable in the FILE (thats file as in code from WINDOWS) struct pointer is zero so it no longer reads) (there is a check in fread to work as long as cnt != 0)

i''m just using fopen to open the file. then the rest is just freading it and saving what is read.

I dont'' need anyone reading thru my code, i''m just wondering if anyone else has come across this and any info they can give me about it.

~code mole~

Share this post


Link to post
Share on other sites
No, noone has come across fread spontaneously ceasing to read. Noone can give you information about it. Good bye.

Or you could post relevant code and we could see where your error is (because it is your error, I guarantee you) and help you.

Share this post


Link to post
Share on other sites
i''m guessing you did an fopen with "r" instead of "rb"
meaning fread will finish early because it reads the file as ascii
not as binary

Share this post


Link to post
Share on other sites