I l@ve RuBoard Previous Section Next Section

16.13 Programming Exercises

Exercise 16-1: Write a program that reads a file and counts the number of lines in it.

Exercise 16-2: Write a program to copy a file, expanding all tabs to multiple spaces. (For historical reasons—the Teletype again—almost all text files use a tab setting of 8 characters.)

Exercise 16-3: Write a program that reads a file containing a list of numbers and writes two files, one containing all the numbers divisible by 3 and another containing all the other numbers.

Exercise 16-4: Write a program that reads an ASCII file containing a list of numbers and writes a binary file containing the same list. Write a program that goes the other way so you can check your work.

Exercise 16-5: Write a program that copies a file and removes all characters with the high bit set (((ch & 0x80) != 0)).

Exercise 16-6: Design a file format to store a person's name, address, and other information. Write a program to read this file and produce a file containing a set of mailing labels.

    I l@ve RuBoard Previous Section Next Section