Static allocation of huge amounts of memory inside the main function

后端 未结 2 666
半阙折子戏
半阙折子戏 2021-01-21 07:03

I have a program that has to declare a huge integer array of the size 1000000 in C (using GNU GCC compiler). I tried to declare the array in two different ways.

The tw

2条回答
  •  清酒与你
    2021-01-21 07:28

    Since you used the word static in the title, it is a wonder that it did not occur to actually declare the variable static.

    int main()
    {
      static int arr[1000000];
      return 0;
    }
    

    You could also use dynamic allocation.

提交回复
热议问题