Clion exit code -1073741571 (0xC00000FD)

北城以北 提交于 2019-12-11 04:59:38

问题


I get a weird exit code in clion:

exit code -1073741571 (0xC00000FD)

This is my code:

int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(nullptr);

    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n = 0, i = 0, j = 0;
    int arr[30007][5];

    for (i = 1; i <= 30000; i++)
        arr[0][i] = 1;

    //...

    return 0;
}

I tested it and find out its because of this line:

int arr[30007][5];

I had no problem in declaration of array in size of less than 1.000.000 2 days ago and now I get this error. I changed nothing in Clion.

What should I do?


回答1:


The error number 0xC00000FD stands for "stack overflow" (I suppose your platform is Windows). Under Windows local variables are allocated on the stack (as on most other platforms too) and int arr[30007][5] is pretty big (30007 * 5 * 4 = 600140 bytes) and stacks are usually rather small (typically around 1 Mb, again platform dependant)

You have many options:

  1. use std::vector instead of raw arrays (preferred)
  2. declare the array as static (static int arr[30007][5];), then it won't reside on the stack anymore
  3. increase the stack size of your executable. This is highly platform/too dependant.
  4. allocate the array dynamically


来源:https://stackoverflow.com/questions/53009030/clion-exit-code-1073741571-0xc00000fd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!