Quote Originally Posted by boxden
first of all, how come you can do this in C++ and not in C

int a[n];
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).

If you are able to use variable length arrays in C++, then you are relying on your compiler's language extension.

Quote Originally Posted by boxden
secondly, why is the array "a" being printed after i freed it in the following piece of code:
Undefined behaviour. You should not be accessing that destroyed array.