Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
995 views
in Technique[技术] by (71.8m points)

c++ - Clion exit code -1073741571 (0xC00000FD)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...