我在 clion 中得到一个奇怪的退出代码:
exit code -1073741571 (0xC00000FD)
这是我的代码:
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;
}
我测试了一下,发现是因为这条线:
int arr[30007][5];
我在 2 天前声明大小小于 1.000.000 的数组 没有问题,现在我收到此错误。 我在 Clion 中没有做任何更改。
我该怎么办?
最佳答案
错误编号 0xC00000FD
代表“堆栈溢出”(我想您的平台是 Windows)。在 Windows 下,局部变量分配在堆栈上(在大多数其他平台上也是如此)并且 int arr[30007][5]
相当大(30007 * 5 * 4 = 600140 字节)并且堆栈通常是相当小(通常约为 1 Mb,同样取决于平台)
你有很多选择:
- 使用
std::vector
代替原始数组(首选) - 将数组声明为静态的(
static int arr[30007][5];
),那么它就不会再驻留在栈上了 - 增加可执行文件的堆栈大小。这是高度平台/过于依赖。
- 动态分配数组
关于c++ - Clion 退出代码 -1073741571 (0xC00000FD),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53009030/