stack overflow

hi there,
Im currently writing a C++ console program, which goes like:

/=========================================================

#include <string.h>
#include <stdlib.h>
#include "time.h"
#include "iostream"
using namespace std;

#define max_iter 100

int main()
{
int a[max_iter][max_iter];
int temp;
const int min = 1;
const int max = 101;

srand((unsigned)time(0));
for (int i = 0;i < max_iter;i++)
for (int j = 0; j< max_iter; j++)
{
temp = min + rand() % max;
a[i][j] = temp;
cout << a[i][j] << " ";
}

getchar();
return 0;
}


/=========================================================
The above code works perfect. However, the problem turned up when I made the following change:
"#define max_iter 100" === >#define max_iter 2000

The compiler shows the warning :"Unhandled exception at 0x004116a7 in wasim2.exe: 0xC00000FD: Stack overflow." I guess the error occurred because of the overlarged size of array. But Im using 2Gb memory. Any idea? Thanks a lot:-)
The stack is usually 1 or 2 MiB.

http://www.cplusplus.com/doc/tutorial/dynamic/
got it... u r awesome.... man

Last edited on
That's why I posted that link.
amazingly powerful, incredibly wonderful:-)
i thought i ned 2 take more practice and pay careful attention on this forum...(free ads:-))
Topic archived. No new replies allowed.