# include char capital ( char c ); int main ( ) // // This program reads characters from the terminal, // and prints them back, capitalized. // // To stop the program, type CTRL-D. // // Note that the program doesn't see your input til you // hit RETURN. // // You can capitalize a file by using the "<" operator. // { char c; int check; while ( 1 ) { // // GETCHAR actually returns an INT, not a CHAR. // This is only so that it can return the special value EOF // when necessary. // // The safest thing to do is store the result of GETCHAR in // an INT, and if the value is not EOF, copy the value into // a character. // check = getchar ( ); if ( check == EOF ) { break; } c = check; c = capital ( c ); putchar ( c ); } return 0; } char capital ( char c ) { if ( 'a' <= c && c <= 'z' ) { c = c - 32; } return c; }