Today I was learning some C++ basics and came to know about wchar_t
. I was not able to figure out, why do we actually need this datatype, and how do I use it?>
I understand most of them have answered it but as I was learning C++ basics too and came to know about wchar_t
, I would like to tell you what I understood after searching about it.
wchar_t
is used when you need to store a character over ASCII 255 , because these characters have a greater size than our character type 'char'. Hence, requiring more memory.
e.g.:
wchar_t var = L"Привет мир\n"; // hello world in russian
It generally has a size greater than 8-bit character.
The windows operating system uses it substantially.
It is usually used when there is a foreign language involved.