
Convert To Upper Case in C++
/*
* 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.