Input and Output

Exercise 1

Create a C-program that reads the characters from the keyboard and shows them on

screen (the inputted characters should only be displayed when the user hits ‘enter’, line

by line).

When ^A is entered, the program must end properly. Then the following message will

appear: “CTRL + A is a correct ending.”

Tip: getchar() reads and putchar() writes the type int. The value of ^A is 1.

Exercise 2

Alter the last program of exercise 1 in such a way that the output doesn’t go to the screen

but is written to a file. The file to write to must be specified by the user.

Leave a Reply

Your email address will not be published. Required fields are marked *