当我执行此代码(gcc 编译)时:
#include <stdio.h>
int main() {
int table[1005][1005];
return 0;
}
它停止工作,但是当我将其更改为:
#include <stdio.h>
int table[1005][1005];
int main() {
return 0;
}
它工作得很好..为什么会发生这种情况?全局变量是否能获得更多空间来分配?为什么?
最佳答案
第一种方法可能是在堆栈上创建数组,第二种方法可能是将其放入“数据段”中。
分配的数量对于堆栈来说可能太大,具体取决于您的平台。
关于C - 全局与局部多维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28445111/