D
D
Denius (genius)2018-11-21 17:27:46
C++ / C#
Denius (genius), 2018-11-21 17:27:46

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

1 answer(s)
R
res2001, 2018-11-21
@Conan_Doyle_SBINH

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 question

Ask a Question

731 491 924 answers to any question