0
Stack array initialization with user input
I tried this: I took an int 'size' as user input and then went and declared an array using the variable for determining its size: char arr[size]; And it worked, not only here but also on my PC. No error, no warning, both in C and C++. I thought that non-heap variables of all sorts must be defined at compile time; but logically, the length of the array will only be known at runtime. Can someone explain me how and why this works?
1 Resposta
+ 2
check this it might help you:
https://en.wikipedia.org/wiki/Variable-length_array