C++ Standard Library C++ STL Library

C++ <cwctype> - towlower() Function



The C++ <cwctype> towlower() function is used to convert the given wide character to lowercase, if it exists. If the lowercase version of the given wide character does not exist, it remains unchanged.

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

Syntax

wint_t towlower ( wint_t ch );              

Parameters

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

Return Value

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

Example:

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

#include <iostream>
#include <cwchar>
#include <cwctype>
using namespace std;
 
int main (){
  wchar_t str[50] = L"HELLO World!";

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

  //displaying the output
  wcout<<str<<"\n";  
  return 0;
}

The output of the above code will be:

hello world!

❮ C++ <cwctype> Library