Unhandled exception at 0x00831D39 in Myfile.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00E42000)

-2

I'm stressed out because of the error (I think only in my computer)

I was able to compile it on this wepsite (https://www.onlinegdb.com/online_c++_compiler) but only fail in my computer.

Anyone who knows why...?

plz help me out

you can only check (int sum[505][505]; //// This part is causing that error) this line

The error is enter image description here

        int N;
        cin >> N;
        int input[500][500];
        int sum[505][505];      //// This part is causing that error
c++
asked on Stack Overflow Apr 11, 2018 by Antonio SEO • edited Apr 11, 2018 by Antonio SEO

1 Answer

0

You're allocating (500*500 + 505*505) * sizeof(int) = 2020100 bytes on the stack. Your stack isn't that big, so it overflows.

You'd be better off using dynamic memory, e.g. by means of a vector<> :

vector<vector<int>> input(500, vector<int>(500));
answered on Stack Overflow Apr 11, 2018 by Sid S • edited Apr 11, 2018 by Sid S

User contributions licensed under CC BY-SA 3.0