towupper() function in C/C++


The function iswupper() is a built-in function in C/C++. It converts the wide character into upper case. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character. If the character is upper case, it is converted into it, otherwise no modifications happen.

Here is the syntax of towupper() in C++ language,

wint_t towupper( wint_t ch );

Here is an example of towupper() in C++ language,

Example

#include <cwchar>
#include <cwctype>
#include <iostream>
using namespace std;
int main() {
   wchar_t s[] = L"hello world!";
   wcout << L"The uppercase string":
   << L"\"is ";
   for (int i = 0; i < wcslen(s); i++)
   putwchar(towupper(s[i]));
   return 0;
}

Output

The uppercase string : HELLO WORLD!

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 24-Jun-2020

148 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements