Run time error on large array sizes in C/C++

This question already has an answer here:

  • Segmentation fault on large array sizes 5 answers

  • In C++, when you're doing this:

    unsigned long long a[100000];
    

    It allocates the memory from the stack. Stack memory is limited so you can't do too big allocations.

    When you do this:

    unsigned long long* a = new unsigned long long[1000000];
    

    It allocates the memory from the heap. Heap allocations can be big.

    More information about stack and heap memory is in this Stack Overflow post.

    链接地址: http://www.djcxy.com/p/79802.html

    上一篇: 如何在解构器中正确释放变量

    下一篇: 在C / C ++中对大数组大小运行时错误