Skip to content
Related Articles

Related Articles

towupper() function in C/C++
  • Last Updated : 23 Aug, 2018

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 a uppercase version, then it is converted into it.
  • If it is not then no modification happens.

Below programs illustrates the above function.



Program 1:




// 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:




// 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!@#

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :