0

I am asking why in this case i should have a constant value in A[size] , but i can't find the answer.

int size;
    cout << "Enter number of elements";
    cin >> size;

    int A[size];

    cout << sizeof A << endl;
  • The size of an array must be a compile-time constant, see [here](https://en.cppreference.com/w/cpp/language/array) for example. – dxiv Dec 05 '20 at 08:23
  • Related: https://stackoverflow.com/questions/1887097/why-arent-variable-length-arrays-part-of-the-c-standard – Lukas-T Dec 05 '20 at 08:42

0 Answers0