-3

So , using codeblocks , i have just written a small cpp program. But it unexpectly shows this error (see image). Can't figure out what's wrong.

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int mat[1000][1000];
    cout<<"done";
    return 0;
}

enter image description here

Piyush Soni
  • 197
  • 2
  • 10

1 Answers1

1

int mat[1000][1000]; is creating a huge array on the stack. Probably more than your compiler/platform allows.

You have several options:

1) tell your compiler to use more space for the stack.

2) allocate your objects on the heap.

3) just stop using C arrays and use a std::vector instead.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70