Answer the question
In order to leave comments, you need to log in
Entering the length of an array value?
Need it but it doesn't work
const int n;
cin >> n;
int arr[n];
Answer the question
In order to leave comments, you need to log in
The way you want to define an array is called VLA (Variable Length Array).
This joke only appeared in C99 and later. There are none in C++.
But even in C programs, not all compilers support them, for example, in MSVC, in my opinion, they have not yet been implemented. True, Microsoft does not claim full support for C standards.
So in C++, as already mentioned in the comments, use either dynamic arrays or std::vector.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question