towupper() function in C/C++

CC++Programming

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!
raja
Published on 08-Oct-2018 09:07:44
Advertisements