------------------------------------------------------------------------------
MC logo
Convert To Upper Case in C++
[^] Code Examples
------------------------------------------------------------------------------
<<Convert To Upper Case allupper.cc Remove Indentation>>
/*
 * Convert the input file to all upper case.
 */
#include <iostream>
#include <cctype>

using namespace std;

int main() 
{
        char inch;              // Input character.

        while(cin.get(inch)) {
                if(isalpha(inch))
                        cout << (char)toupper(inch);
                else
                        cout << inch;
        }
}

Note that we require a cast when printing the result of toupper, otherwise, it prints the ascii value of the character.
<<Convert To Upper Case Remove Indentation>>