------------------------------------------------------------------------------
MC logo
Convert To Upper Case
[^] Code Examples
------------------------------------------------------------------------------
<<Print the ASCII Set allupper.c Convert To Upper Case in C++>>
/*
 * 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.
<<Print the ASCII Set Convert To Upper Case in C++>>