It depends on whether you are writing C or C ++. I assume that C for C ++ is better for you to use std :: vector, rather than an array.
In C, it depends on which option you are using. If and only if you use the standard C99 compiler, then the array can take its size from the variable at run time, as you do, otherwise the size must be determined at compile time. Visual Studio does not support dynamic array - see MSDN
C ++ uses the C89 standard, so it requires that the size be set at compile time.
So, in your case, you need to see which flags you passed to the compiler.
As @Eric noted, C ++ code, so the working compiler uses a non-standard extension, so for gnu I would add flags to enforce the standard, like -ansi or -std = C ++ 98 and -pedantic
Mark
source share