Declaring the array size with a non-constant variable
You are using a feature from C99 which is called VLA(variable length arrays). It would be better if you compile your program like this:
g++ -Wall -std=c++98 myprog.cpp
This is a GCC extension to the standard:
You can use the -pedantic
option to cause GCC to issue a warning, or -std=c++98
to make in an error, when you use one of these extensions (in case portability is a concern).