Open In App

towupper() function in C/C++

Improve
Improve
Like Article
Like
Save
Share
Report

The towupper() is a built-in function in C/C++ which converts the given wide character into uppercase. It is defined within the cwctype header file of C++. Syntax:

wint_t towupper( wint_t ch )

Parameter: The function accepts a single mandatory parameter ch which specifies the wide character which we have to convert into uppercase. Return Value: The function returns two values as shown below.

  • If the ch has an uppercase version, then it is converted into it.
  • If it is not then no modification happens.

Below programs illustrates the above function. Program 1

CPP




// Program to illustrate
// towupper() function
#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main()
{
 
    wchar_t str[] = L"GeeksforGeeks";
    wcout << L"The uppercase version of \""
          << str << L"\" is ";
 
    for (int i = 0; i < wcslen(str); i++)
        // Function to convert the character
        // into the uppercase version, if exists
        putwchar(towupper(str[i]));
 
    return 0;
}


Output:

The uppercase version of "GeeksforGeeks" is GEEKSFORGEEKS

Program 2

CPP




// Program to illustrate
// towupper() function
#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main()
{
 
    wchar_t str[] = L"hello Ishwar 123!@#";
    wcout << L"The uppercase version of \""
          << str << L"\" is ";
 
    for (int i = 0; i < wcslen(str); i++)
        // Function to convert the character
        // into the uppercase version, if exists
        putwchar(towupper(str[i]));
 
    return 0;
}


Output:

The uppercase version of "hello Ishwar 123!@#" is HELLO ISHWAR 123!@#


Last Updated : 13 Feb, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads