4 ms·
https://pubs.opengroup.org/onlinepubs/007904975/functions/fread.html https://pubs.opengroup.org/onlinepubs/007904975/functions/fr... "The fread() function shal
by eqvinox 4y ago
https://pubs.opengroup.org/onlinepubs/007904975/functions/fread.html https://pubs.opengroup.org/onlinepubs/007904975/functions/fr...
"The fread() function shall read into the array pointed to by ptr up to nitems elements whose size is specified by size in bytes, from the stream pointed to by stream. For each object, size calls shall be made to the fgetc() function and the results stored, in the order read, in an array of unsigned char exactly overlaying the object. […] If a partial element is read, its value is unspecified."
It doesn't say you stop when fgetc() returns EOF (or an error), so by a strict reading the remainder of partial items is filled with fgetc()'s "EOF" return value. But the more relevant thing is that it says the value of a partial element is unspecified.
(Edited to point out the "unspecified" aspect.)