/* * Convert the input file to all upper case. */ #include <stdio.h> #include <ctype.h> int main() { int inch; /* Input character. */
while((inch = getchar()) != EOF) { if(isalpha(inch)) putchar(toupper(inch)); else putchar(inch); } }
This uses a frequent idiom for reading the input one character at a time
in plain C:
while((inch = getchar()) != EOF) { . . . } The body is executed once for each character in the input file,
with the variable inch taking on each character value.