# include char capital ( char c ); int main ( ) // // This program reads characters from the text file "input.txt", // and writes them, capitalized, to another file, "output.txt". // { char c; int check; FILE *input; FILE *output; input = fopen ( "input.txt", "rt" ); output = fopen ( "output.txt", "wt" ); while ( 1 ) { // // FGETC 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 = fgetc ( input ); if ( check == EOF ) { break; } c = check; c = capital ( c ); fputc ( c, output ); } fclose ( input ); fclose ( output ); return 0; } char capital ( char c ) { if ( 'a' <= c && c <= 'z' ) { c = c - 32; } return c; }