G
Guest
I use:
I use:
------------
a = fread(buffer, 100, 1, file);
------------
usually a = 100, but there are cases where a == 1!
There is no file problem or eof because when change to
------------
a = fread(buffer, 1, 100, file);
------------
there is no problem and a is always 100!
Why?
Maybe a library error?
I use:
------------
a = fread(buffer, 100, 1, file);
------------
usually a = 100, but there are cases where a == 1!
There is no file problem or eof because when change to
------------
a = fread(buffer, 1, 100, file);
------------
there is no problem and a is always 100!
Why?
Maybe a library error?
I use:
------------
a = fread(buffer, 100, 1, file);
------------
usually a = 100, but there are cases where a == 1!
There is no file problem or eof because when change to
------------
a = fread(buffer, 1, 100, file);
------------
there is no problem and a is always 100!
Why?
Maybe a library error?
I use:
There is no file problem or eof because when change to
It always returns the count of full items read. Here is an
excerpt from C99 7.19.8.1 "The fread function":
Returns
3 The fread function returns the number of elements
successfully read, which may be less than nmemb if a read
error or end-of-file is encountered. If size or nmemb is
zero, fread returns zero and the contents of the array and
the state of the stream remain unchanged.
Don Starr said:Yes, I've read that description in several places (man pages, etc.). However, while it says "may be
less than", it does not say "will not be more than".
Don Starr said:I'm still trying to figure it out. I have not yet seen any information that allows me to logically
conclude that the return value will not be greater than the specified count.
I've seen
* "reads up to" specified count
* returns count of items read
<- Chameleon -> said:My program are multithreaded and my variable are static. So, another thread
changes my variable.
I must use mutual exclusion.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.