4 ms·
fread and fwrite do their thing on N chunks of M bytes each, and fread returns the number of chunks that it managed to read. So the write writes 1 chunk of `num
by to3m 14y ago
fread and fwrite do their thing on N chunks of M bytes each, and fread returns the number of chunks that it managed to read. So the write writes 1 chunk of `number' byte each, then the read reads `number' chunks of `divisor' bytes each (obviously this value will be larger than the number of bytes in the file). And by returning the number of `divisor'-byte chunks needed to read a file of `number' bytes in size, you get your answer.
This just goes to prove that fread and fwrite are the biggest pile of crap.