int array[strlen(argv[2])];
This, of course, is invalid C ++ Standard code, because it defines a variable length array (VLA), which is not allowed in any version of the C ++ ISO standard. It is valid only in the C99. And in non-standard versions of the implementation of C or C ++. GCC provides VLA as an extension, also in C ++.
So, you have the first option. But donβt worry, you donβt even need it, as you have an even better option. Use std::vector<int>
:
std::vector<int> array(strlen(argv[2]));
Use it.
Nawaz source share