What is the "short item count" in fread ()?

When I was human, I received the following:

RETURN VALUE
fread () and fwrite () return the number of elements that were successfully read or written (i.e. not the number of characters). If an error occurs (), then the return value is a short counter (or zero).

fread () does not distinguish between the final file and the error, and callers should use the feof (3) and ferror (3) functions to determine what happened.

So my question is how to understand the “short item counter”. Please speak my English. Why is it meant to be short? Can you give someone an example of what a “short item counter” looks like? Thanks.

+7
source share
2 answers

If you want 4, and you have 3, then you will be 1.

+4
source

The value "short" on the fread man page is not a data type.

"Short" in this case means "less than expected." If fread () should read 4 objects, but only read 3, it will return 3.

I believe that the manual page should be rewritten to say: "If an error occurs or the end of the file is reached, the return value is the number of elements that were successfully read or written until an error or EOF occurs.

+5
source

All Articles