[prev] 46 [next]

Exercise 4: (FILE *) vs FileDesc

Write three programs to scan a file and write it to stdout
  • for one use stdio.h and read char-by-char
  • for one use stdio.h and read line-by-line
  • for one use unistd.h and read block-by-block
Notes:
  • stdout is accessible via file descriptor 1
  • check whether the size of read()'s buffer matters
  • system calls are relatively expensive operations