What is the use of wchar_t in general programming?

前端 未结 7 1807
忘掉有多难
忘掉有多难 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:45

    wchar_t is a wide character. It is used to represent characters which require more memory to represent them than a regular char. It is, for example, widely used in the Windows API.

    However, the size of a wchar_t is implementation-dependant and not guaranteed to be larger than char. If you need to support a specific form of character format greater than 8 bits, you may want to turn to char32_t and char16_t which are guaranteed to be 32 and 16 bits respectively.

提交回复
热议问题