Unless n is a constant positive integer, you cannot do that in C++, but under certain circumstances you can do that in C even if n is not a constant, with respect to the 1999 edition of the C standard (this is the variable length array feature).Originally Posted by boxden
If you are able to use variable length arrays in C++, then you are relying on your compiler's language extension.
Undefined behaviour. You should not be accessing that destroyed array.Originally Posted by boxden