内存问题消息

时间:2012-04-16 08:01:10

标签: visual-c++

我对我执行C ++代码时显示的错误消息有疑问,错误消息如下:

Exception non gérée à 0x00839057 dans FirstReport1.exe : 0xC00000FD: Stack overflow.

1)这是什么意思? 2)我怎样才能避免它并正常执行我的代码? 我正在执行的代码如下:

#include <iostream>
#include <fstream>
#include <ctime>
#include <iomanip>

using namespace std;

const int width(10001);
const int height(15);

void main()
{
    ifstream inputfile ("file6.txt");
    ofstream outputfile ("outfile.txt");
    ofstream filteredfile ("filteredfile.txt");
    ofstream timefile ("time.txt");
clock_t tstart, tend;
tstart = clock();

int i, x, y;
double tab[height][width];

for (y=0; y<height; y++){
    for (x=0; x<width; x++){
        tab[y][x]=0;
    }
}

if (inputfile){
    for (y=0; y<height; y++){
        for (x=0; x<width; x++){ 
            inputfile >> tab[y][x];
        }
    }
}

if (filteredfile){
    for (y=0; y<height-1; y++){
        for (x=0; x<width-1; x++){
            if (tab[y+1][x+1]==-9999 || tab[y+1][x+1]<20 || tab[y+1]

[x+1]>1200) {tab[y+1][x+1]= 0;}
                filteredfile << tab[y][x] << '\t';
            }
        }
    }
tend = clock();
    double time;
    time = double (tend-tstart)/CLOCKS_PER_SEC;
    timefile << time;
}

1 个答案:

答案 0 :(得分:1)

您正在堆栈上创建一个数组“tab”,其中包含10001x15个元素。每个元素都是一个double,大小为8个字节。因此,该数组为1,200,120字节,可能大于默认堆栈大小。我记得在Visual c ++中这是1MB。

将此数组放在堆栈以外的某个位置,或者增加堆栈大小。