Whole document tree
4.14 Arrays of Variable LengthVariable-length automatic arrays are allowed in GNU C. These arrays are declared like any other automatic arrays, but with a length that is not a constant expression. The storage is allocated at the point of declaration and deallocated when the brace-level is exited. For example:
Jumping or breaking out of the scope of the array name deallocates the storage. Jumping into the scope is not allowed; you get an error message for it.
You can use the function
There are other differences between these two methods. Space allocated
with You can also use variable-length arrays as arguments to functions:
The length of an array is computed once when the storage is allocated
and is remembered for the scope of the array in case you access it with
If you want to pass the array first and the length afterward, you can use a forward declaration in the parameter list--another GNU extension.
The `int len' before the semicolon is a parameter forward
declaration, and it serves the purpose of making the name You can write any number of such parameter forward declarations in the parameter list. They can be separated by commas or semicolons, but the last one must end with a semicolon, which is followed by the "real" parameter declarations. Each forward declaration must match a "real" declaration in parameter name and data type.
This document was generated by root on January, 30 2002 using texi2html |