toupper c++ string code example

Example 1: c++ char to uppercase

char choice; 
// it will instantly transform it to upper case without the need
// to convert it to int first
choice = (char)toupper(choice);

Example 2: convert all characters in string to uppercase c++

transform(str.begin(), str.end(), str.begin(), ::toupper);

Example 3: toupper c++

int result = toupper(charecterVariable);// return the int that corresponding upper case char
//if there is none then it will return the int for the original input.
//can convert int to char after
char result2 = (char)toupper(variableChar);

Tags:

Cpp Example