What is the use of wchar_t in general programming?

前端 未结 7 1763
忘掉有多难
忘掉有多难 2020-12-24 01:09

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?

7条回答
  •  礼貌的吻别
    2020-12-24 01:56

    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.

    1. 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
      
    2. It generally has a size greater than 8-bit character.

    3. The windows operating system uses it substantially.

    4. It is usually used when there is a foreign language involved.

提交回复
热议问题