hvn-network

My Blog List

Tuesday, September 20, 2016

[C programming] Exercises on Input, output

We cover exercises on Input, Output from book "The C programming language".

File copy

Count characters in input

Count line

Exercise 1-8. Write a program to count blanks, tabs, and newlines.
Solution

Exercise 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.
Solution

Exercise 1-10. Write a program to copy its input to its output, replacing each tab by \t, each backspace by \b, and each backslash by \\. This makes tabs and backspaces visible in an unambiguous way.
Solution

Count word

Convert to lower case

Exercise 7-1. Write a program that converts upper case to lower or lower case to upper, depending on the name it is invoked with, as found in argv[0].
Solution

Exercise 7-2. Write a program that will print arbitrary input in a sensible way. As a minimum, it should print non-graphic characters in octal or hexadecimal according to local custom, and break long text lines.
Solution

Exercise 7-3. Revise minprintf to handle more of the other facilities of printf.
Solution

Exercise 7-4. Write a private version of scanf analogous to minprintf from the previous section.
Solution

Exercise 7-5. Rewrite the postfix calculator of Chapter 4 to use scanf and/or sscanf to do the input and number conversion.
Solution

Copy File

Fgets Fputs Getline

Exercise 7-6. Write a program to compare two files, printing the first line where they differ.
Solution

Exercise 7-7. Modify the pattern finding program of Chapter 5 to take its input from a set of named files or, if no files are named as arguments, from the standard input. Should the file name be printed when a matching line is found?
Solution

Exercise 7-8. Write a program to print a set of files, starting each new one on a new page, with a title and a running page count for each file.
Solution

Exercise 7-9. Functions like isupper can be implemented to save space or to save time. Explore both possibilities.
Solution














No comments:

Post a Comment