Why no variable size array in stack?

后端 未结 7 1183
南方客
南方客 2020-11-27 19:28

I don\'t really understand why I can\'t have a variable size array on the stack, so something like

foo(int n) {
   int a[n];
}

As I underst

7条回答
  •  一整个雨季
    2020-11-27 20:04

    Because the language specification says so. Nothing else matters (and explaining with segments is terribly wrong for different reasons).

提交回复
热议问题