A variable-length array (VLA) is a C array whose bound is not an integer constant expression, so its size is determined at run time. VLAs were mandatory in C99, became optional in C11, and remain optional for automatic objects in C23; VLA types, pointers to them, and VLA parameters are mandatory in C23. section 6.1.3
Keep these declaration and usage rules in view:
- Declare VLAs only inside functions; they cannot be declared outside functions. section 6.1.3
- Give a VLA a strictly positive bound. section 6.1.3
- Use only default initializers for VLAs. section 6.1.3
- Distinguish VLAs from fixed-length arrays: a fixed-length array has a bound supplied by an integer constant expression or inferred from its initializer. section 6.1.3
A VLA's lifetime begins when execution encounters its definition and ends when its visibility scope is left. Unlike other automatic objects, it cannot be used earlier in the same block, because its storage cannot be allocated until its run-time size is known. section 13.3
VLAs consume dynamically determined function-context storage, commonly associated with the stack. Their size can make exhaustion difficult to estimate, although replacing a large fixed-length array with a VLA may reduce stack usage. The C standard provides no way to predict stack exhaustion; check __STDC_NO_VLA__ when portability matters. section 15.2.2

