Why does C++ allow variable length arrays that aren’t dynamically allocated?

Support for variable length arrays (VLAs) was added to the C language in C99. It’s likely that since support for them exists in gcc (to support C99), it was relatively straightforward to add support for them to g++. That said, it’s an implementation-specific language extension, and it’s not a good idea to use implementation-specific extensions … Read more

Variable Length Array (VLA) in C++ compilers

Why does the compiler accept that declaration? Because its authors chose to make it do so. GCC in particular allows, by default, a lot of non-standard stuff that was historically accepted by old C compilers. They like “compatibility” in that sense. What does the standard say about [it]? Precisely what the warning states it says … Read more

C dynamically growing array

I can use pointers, but I am a bit afraid of using them. If you need a dynamic array, you can’t escape pointers. Why are you afraid though? They won’t bite (as long as you’re careful, that is). There’s no built-in dynamic array in C, you’ll just have to write one yourself. In C++, you … Read more