简体   繁体   中英

Memory problems message

I have a question about an error message that is displayed whenever I execute my C++ code, the error message is as follows:

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

1) what does this mean? 2) how can I avoid it and execute my code normaly? the code i am executing is the following:

#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;
}

You're creating an array "tab" on the stack, which has 10001x15 elements. Each element is a double, which is 8 bytes in size. So the array is 1,200,120 bytes which may be larger than the default stack size. I recall this is 1MB in Visual c++.

Either put this array somewhere other than the stack, or increase your stack size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM