[Solved] Why this C++ program complies and runs in CodeBlocks [duplicate]


Variable-length arrays are not a C++ feature, so this line will cause a compilation error in a compiler that is ordered to strictly adhere to the C++ specification, regardless of the value of n (unless n is const and can be determined at compile-time):

int array[n];

Likely you are using a compiler that supports variable-length arrays as an extension. Therefore, the rules regarding what is valid depend entirely on the specific compiler and compiler options, and any code that you write using this extension will not be portable to compilers that don’t support this non-standard feature.

2

solved Why this C++ program complies and runs in CodeBlocks [duplicate]