0

Hello,

Is there any limitation for the length of array variables in C++?

Can I specify the length as wanted or is there any limitation for the array length? What should be the array length, if the length is not known.

wchar_t commandString[10000];

Cheers

4
Contributors
6
Replies
26
Views
1 Year
Discussion Span
Last Post by rubberman
0

Hi,

If you include the header limits in your program you can get the limit of wchar_t max to be 65535 and lowest to be 0. Something like thus:

#include <iostream>
#include <limits>

int main() {

    std::cout << "lower limit for wchar_t: "
        << std::numeric_limits<wchar_t>::min()
    << "\nupper limit for wchar_t: "
    << std::numeric_limits<wchar_t>::max()
    << std::endl;

    return 0;
}

Of course, if your intension is to use string value in c++ is better you are using std::string not c string like it was pointed out previously.

Hope this helps.

Edited by 2teez

0

And if you need wide chars in your C++ string use std::wstring instead of std::string. All that wchar_t is is a wide (2 byte) character that can contain unicode characters. It is a common C type for systems that have to support international languages.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.