Segmentation fault on large array sizes

后端 未结 5 1832
醉梦人生
醉梦人生 2020-11-21 04:33

The following code gives me a segmentation fault when run on a 2Gb machine, but works on a 4GB machine.

int main()
{
   int c[1000000];
   cout << \"do         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-21 05:11

    You array is being allocated on the stack in this case attempt to allocate an array of the same size using alloc.

提交回复
热议问题