http://qs321.pair.com?node_id=1008

File Input and Output Exercises

  1. Write a program which prompts the user for the name of a file to open, and then reads in the file line by line. When it has finished reading the file it should print the lines in reverse order. (solution)
  2. Write a program which asks the user to type the name of a file to log their typing into, and then reads in lines and writes them into the named file, stopping when it has read a line consisting only a "." on a line by itself. (solution)
  3. Write a program which copies one file to another. The program should take two command line arguments, the first being the source file name and the second being the destination file name. (solution)