Facebook Page Twitter Page LinkedIn Page
× C Standard Library


The C <wctype.h> towupper() function is used to convert the given character to uppercase, if it exists. If the uppercase version of the given wide character does not exist, it remains unchanged.

The following lowercase letters abcdefghijklmnopqrstuvwxyz are replaced with respective uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ.

Syntax

wint_t towupper ( wint_t c );              

Parameters

ch Specify the wide character to be converted, casted to an wint_t, or WEOF.

Return Value

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

Example:

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

#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
 
int main (){
  wchar_t str[50] = L"HELLO World!";

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

  //displaying the output
  printf("%ls\n", str);  
  return 0;
}

The output of the above code will be:

HELLO WORLD!

❮ C <wctype.h> Library