Programming Exercises

  1. Write a file copy program that takes the original filename and the copy file from the command line. Use standard I/O and the binary mode, if possible.

  2. Write a program that sequentially displays onscreen all the files listed in the command line. Use argc to control a loop.

  3. Modify the program in Listing 12.6 so that it uses a command-line interface instead of an interactive interface.

  4. Programs using command-line arguments rely on the user's memory of how to use them correctly. Rewrite the program in Listing 12.2 so that, instead of using command-line arguments, it prompts the user for the required information.

  5. Write a program that opens two files whose names are provided by command-line arguments.

    1. Have the program print line 1 ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.