Variable-length array
A variable-length array is an array whose bound is determined at run time rather than fixed as a compile-time constant.
Modern C, Third Edition
A variable-length array is a C array whose bound is determined at run time rather than being an integer constant expression.
- How it is used
- Explains run-time-sized arrays through declaration constraints, lifetime rules, portability, and storage-exhaustion risks.
- How deep it goes
- Descends from classification to initialization, scope, lifetime, and stack behavior, but does not develop a complete implementation example.
- Examples
- Uses array-length classification, initializer-based fixed arrays, a control-flow lifetime example, and stack-exhaustion scenarios.
- What you can do after
- Evaluate VLA declarations for validity, lifetime behavior, portability, and potential stack exhaustion.
Read how Modern C, Third Edition explains variable-length array →
Modern C
A variable-length array is a C array whose length is determined at run time and whose lifetime rules differ from those of ordinary automatic objects.
- How it is used
- Distinguishes run-time-sized arrays from fixed-length arrays and establishes their declaration and lifetime restrictions.
- How deep it goes
- Defines classification, restrictions, length calculation, and lifetime, but defers broader storage details.
- Examples
- Uses initializer-sized arrays, a sizeof-based length formula, and a control-flow example contrasting VLA and non-VLA lifetime.
- What you can do after
- Apply C declaration rules to classify arrays, calculate array length, and reason about when VLA storage is valid.
What to know first
- integer constant expressionAn integer constant expression is an expression whose value can be determined during translation using only permitted constant operands and operations.
- initializerAn initializer is a function, declaration, or language construct that establishes an initial value or state for an object, value, or computation.
- referenceA reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
- undefined behaviorUndefined behavior is program execution or an operation for which the applicable specification imposes no requirements on the resulting behavior.
Related concepts
- lifetimecontrasts with · A lifetime is the interval during which a program entity exists and remains valid or accessible under the applicable language rules.
- arraykind of · An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- initializercontrasts with · An initializer is a function, declaration, or language construct that establishes an initial value or state for an object, value, or computation.
- gotocontrasts with · A goto statement or instruction unconditionally transfers program execution to a labeled statement or location within the current execution unit.
- C99configured by · C99 is the ISO standard revision of the C programming language published in 1999.
Questions about variable-length array
What is variable-length array?
A variable-length array is an array whose bound is determined at run time rather than fixed as a compile-time constant.
Which Manning books explain variable-length array?
Modern C, Third Edition and Modern C.
What should I know before learning variable-length array?
Manning books that teach variable-length array usually introduce integer constant expression, initializer, reference and undefined behavior first.
What is the difference between variable-length array and lifetime?
A variable-length array is an array whose bound is determined at run time rather than fixed as a compile-time constant. A lifetime is the interval during which a program entity exists and remains valid or accessible under the applicable language rules.
What is variable-length array a kind of?
Variable-length array is a kind of array. An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

