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

Recommended Answers

All 6 Replies

So wchar_t is a C string?

I thought it was C++ string?

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.