CS360 Midterm -- October 18, 1999. Question 3: Answer and grading

7 points

First off, the standard I/O library performs buffering of the write() calls. Instead of performing one write() call per 4 bytes of the file, it buffers them in a 4K or 8K buffer, and performs one write() call when the buffer is full. This is one write() call for every 1024 or 2048 fwrite() calls.

Additionally, the standard I/O library is a convenient interface. You could do the buffering yourself by allocating a large array, copying the 4 bytes to it one at a time, and writing it when it gets full, but it is much easier to simply call fwrite() and to let the standard I/O library do it for you.

Grading -- you had to mention buffering and make some mention of convenience to get full credit. Buffering was 5 points (and you had to give a decent explanation, not simply a mention of buffering), and convenience was 2 points.