Exercise 5-1 - CBD page 198 - Lone Leth Thomsen

Solution index                   Textual C program


/** Solution to exercise 5.1, p. 198, "C by Dissection"
 *
 *
 * Reads a character from the keyboard and writes to the screen. Every letter
 * that is read is written three times, followed by newline
 *
 * 07. March, Lone Leth Thomsen
 **/


#include <stdio.h>

int main(void)
{
	char c;

	while((c = getchar()) != EOF) {
		if (c!='\n'){
		putchar(c);
		putchar(c);
		putchar(c);
		putchar('\n');
	    }
	  
	}
	return 0;
}

	while((c = getchar()) != EOF) {
reads a character and checks that it is not EOF
 

		if (c!='\n'){
checks that the character is not newline
 


Generated: Wednesday, March 29, 2006, 12:33:26
This program dissection page is generated from an XML-in-LAML source file