Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable Length Array

Tags:

c

c99

I would like to know how a variable length array is managed (what extra variables or data structures are kept on the stack in order to have variable length arrays).

Thanks a lot.

like image 870
user331561 Avatar asked May 03 '10 15:05

user331561


1 Answers

It's just a dynamically sized array (implementation-dependent, but most commonly on the stack). It's pretty much like alloca in the old days, with the exception that sizeof will return the actual size of the array, which implies that the size of the array must also be stored somewhere (implementation-dependent as well, but probably on the stack too).

like image 84
Paul R Avatar answered Oct 18 '22 01:10

Paul R