Variable length arrays (VLA) in C and C++

后端 未结 5 2095
旧巷少年郎
旧巷少年郎 2020-11-30 06:07

Possible Duplicate:
Variably modified array at file scope

I have some concepts about the VLA and its behavior

5条回答
  •  离开以前
    2020-11-30 06:52

    I think the fundamental reason is a global variable has linkage, its size has to be known at compile time. If not, how could one link the program?

    local variables have no linkage and the VLAs are allocated on the stack, which grows dynamically as the program runs.

提交回复
热议问题