Popular Google Pages:
◕ Bengali Story writing competition. More..
◕ This article is regarding What is wchar_t in C++?
Last updated on: 25th December 2016.
◕ What is wchar_t in C++?
- Sometimes C++ have to handle certain character sets that don’t fit within the allotted 8-bit byte of char type.
For example, the Japanese kanji system.
C++ handles this type of character sets with wchar_t.
The full form of the wchar_t is Wide Character Type.
It represents the extended character set.
The wchar_t type is an integer type with sufficient space to represent the largest extended character set.
◕ The cin and cout family are not suitable for wchar_t.
Instead we use wcin and wcout for handling wchar_t streams.
The example codes are given bellow:
▨ wchar_t flower = L'P'; // a wide-character constant
▨ wcout << L" Beautiful Flower " << endl; // outputting a wide-character string
Here preceding L is used to indicate the wide-character-type constant or string.
◕ Please note:
On a system with a 2-byte wchar_t, this code stores each character in a 2-byte unit of memory which is very large.
As C++ experience more with Unicode, it became clear that the wchar_t type is not enough for describing character sets. For this we need char16_t and char32_t.
What is char16_t and char32_t in C++?
Integer Type in C++
Rules for Variable Names
Variable in C++
Fundamental Data Types & Compound Data Types
What is called Directive and Header File in C++ ?
What is Block Statement in C++ ?
Top of the page