Berkeley CSUA MOTD:Entry 26288
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2024/11/27 [General] UID:1000 Activity:popular
11/27   

2002/10/23-24 [Uncategorized] UID:26288 Activity:low 50%like:26384
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.