The behaviour of allowing the following code to compile: cin >> x; int a[x];
by gcc/g++ is due to historical reasons. This kind of a declaration is called a variable length array however it is not supported by the C++ and C standards. To prove that this is the case, recompile with g++ -pedantic <file.cpp> You get: vla.cpp:8:9: warning: ISO C++ forbids variable length array ‘a’ -- DK -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/iRg-lRTKNLUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.