Question: what is the difference between variable length array and dynamic memory allocation?
Answer: The most notable difference is scope. The VLA array will only be valid inside the scope where it is declared, while a dynamic array will be available everywhere in the program until you call free() . In practice, VLAs may be faster than dynamic memory, in case the compiler use stack allocation for the VLA.