Question:
What is the size of wchar_t in C++?
C ++ में wchar_t का आकार क्या है?
Options:
- 2
- 4
- 2 or 4
- Based on the number of bits in the system
- 2
- 4
- 2 या 4
- सिस्टम में बिट्स की संख्या केपर आधारित
Correct Answer: d)
Explanation:
Detailed Explanation:
The correct answer is d) Based on the number of bits in the system / implementation (सिस्टम में बिट्स की संख्या केपर आधारित).
In C and C++:
- The data type
wchar_t(wide character) is designed to represent character encodings that require more than the single byte (8 bits) provided by standardchar, such as Unicode characters and international character sets. - According to the ISO/IEC C++ standard, the size of
wchar_tis implementation-defined:- On Microsoft Windows systems (MSVC compiler),
wchar_tis 16 bits (2 bytes) wide, representing UTF-16 code units. - On Linux and Unix platforms (GCC / Clang),
wchar_tis typically 32 bits (4 bytes) wide, representing UTF-32 code units.
- On Microsoft Windows systems (MSVC compiler),
- Consequently, its size is not fixed universally by the language grammar; rather, it depends on the compiler, platform architecture, and system bits.
विस्तृत व्याख्या:
सही उत्तर d) सिस्टम में बिट्स की संख्या केपर आधारित है।
C++ में wchar_t (Wide Character Type):
wchar_tडेटा प्रकार का उपयोग बड़े कैरेक्टर सेट (जैसे यूनिकोड या अंतरराष्ट्रीय भाषाएँ) का प्रतिनिधित्व करने के लिए किया जाता है, जो साधारण 1-बाइटcharमें समाहित नहीं हो सकते।- C++ मानक के अनुसार,
wchar_tका आकार कार्यान्वयन-परिभाषित (Implementation-defined) होता है, जो कंपाइलर और सिस्टम आर्किटेक्चर पर निर्भर करता है:- विंडोज (Windows) प्लेटफॉर्म पर इसका आकार सामान्यतः 16 बिट्स (2 बाइट्स) होता है (UTF-16)।
- लिनक्स और यूनिक्स (Linux/Unix) प्लेटफॉर्म पर इसका आकार सामान्यतः 32 बिट्स (4 बाइट्स) होता है (UTF-32)।
- अतः इसका आकार सिस्टम में बिट्स और कंपाइलर आर्किटेक्चर पर आधारित होता है।