What is the use of wchar_t in general programming?

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

    The wchar_t type is used for characters of extended character sets. It is among other uses used with wstring which is a string that can hold single characters of extended character sets, as opposed to the string which might hold single characters of size char, or use more than one character to represent a single sign (like utf8).

    The wchar_t size is dependent on the locales, and is by the standard said to be able to represent all members of the largest extended character set supported by the locales.

提交回复
热议问题