在C ++中创建一个大数组 [英] Create a big array in C++
本文介绍了在C ++中创建一个大数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
大数组大小上的分段故障
我试图在VS 2010中使用C ++创建一个非常大的数组。
创建如下的数组
int dp [4501] [4501]
或
int dp [1000 ] [1000]
它引发了一个异常Stack Overflow
然后将其更改为:
int dp [100] [100]
一切都很好。
所以如果我想创建一个像上面那样的大数组, p>
最好的问候,
解决方案
使用动态分配或STL。最近有一个线程提出了一个非常类似的问题。请参见此。
Possible Duplicate:
Segmentation fault on large array sizes
Hi all
I am trying to create a very big array in the VS 2010 using C++.
When I try to create a array like below
int dp[4501][4501]
or
int dp[1000][1000]
It threw an exception "Stack Overflow" Then I change it to:
int dp[100][100]
everything is fine.
So if I want to create a big array like above, what should I do?
Best Regards,
解决方案
Use dynamic allocation or the STL. There was a recent thread about a very similar question. See this.
这篇关于在C ++中创建一个大数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文