Facebook Page Twitter Page LinkedIn Page
× C++ Standard Library C++ STL Library

The C++ <cctype> toupper() function is used to convert the given character to uppercase according to the character conversion rules defined by the currently installed C locale.

In the default "C" locale, the following lowercase letters abcdefghijklmnopqrstuvwxyz are replaced with respective uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ.


int toupper ( int ch );               


ch Specify the character to be converted, casted to an int, or EOF.

Return Value

Returns uppercase version of ch or unchanged ch if no uppercase value is listed in the current C locale.


The below example shows the usage of toupper() function.

#include <iostream>
#include <cctype>
using namespace std;
int main (){
  char str[50] = "HELLO World!";

  //converting str into upper case
  int i = 0;
  while(str[i]) {
    str[i] = toupper(str[i]);

  //displaying the output
  return 0;

The output of the above code will be:


❮ C++ <cctype> Library