Download Programming from the Ground Up
Transcript
Chapter 5. Dealing with Files Use the Concepts • Modify the toupper program so that it reads from STDIN and writes to STDOUT instead of using the files on the command-line. • Change the size of the buffer. • Rewrite the program so that it uses storage in the .bss section rather than the stack to store the file descriptors. • Write a program that will create a file called heynow.txt and write the words "Hey diddle diddle!" into it. Going Further • What difference does the size of the buffer make? • What error results can be returned by each of these system calls? • Make the program able to either operate on command-line arguments or use STDIN or STDOUT based on the number of command-line arguments specified by ARGC. • Modify the program so that it checks the results of each system call, and prints out an error message to STDOUT when it occurs. 66