10/22 dumb C question: what's the difference between
fread(buf, m, n, fp)
fread(buf, n, m, fp)
fread(buf, m * n, 1, fp)
fread(buf, 1, m * n, fp) ?
\_ The last one reads any number of bytes between 0 and m*n, and
returns the number of bytes read; the first one is guaranteed
to read some multiple of m bytes, and returns the number of
m-byte chunks read.
\_ AFAIK, fread() takes chunk size and number because some
operating systems' i/o API was based on chunks -- unlike
Unix which uses bytes. fread() is in the ANSI standard library,
so the concept of chunk was added for portability.
-- misha. |