C++ Standard Library C++ STL Library

C++ <cwchar> - wchar_t Type



The wchar_t is an implementation-defined wide character type. It represent distinct codes for all members of the wide character set specified among the supported locales.

In C++, wchar_t is a distinct fundamental type and thus it is not defined in <cwchar> nor in any other header. In C, this is a typedef of an integer type.

Example:

The example below shows the usage of wchar_t type.

#include <iostream>
#include <cwchar>
using namespace std;
 
int main (){
  //initiating a variable str of 
  //wchar_t type
  wchar_t str[256] = L"Hello World!.";

  wcout<<"str contains: "<<str;
  return 0;
}

The output of the above code will be:

str contains: Hello World!.

❮ C++ <cwchar> Library