Unhandled Exception !

hey...when i debug my codes, it showed up this error:

"Unhandled exception at 0x00155EB7 in Calculator 2.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00502000)."

what's this and how should i fix it?
It means you've allocated something on the stack (which is a limited size) that exceeded the size of the stack. Allocate on the heap instead with new() operator:

1
2
int stackInt[1000]; // on the stack
int *heapInt = new int[1000]; // on the heap 
You could also get a stack overflow if you call a function recursively too many times.

1
2
3
4
5
6
7
8
9
10
11
void foo()
{
	foo();
}

// foo()
//  -> foo()
//      -> foo()
//          -> foo()
//              ...
//                  *eventually you run out of stack space* 
Last edited on
my arrays's sizes is 100000! is it too big?!
Computers use different stack sizes so it's hard to say if it's enough to cause a crash on its own. It also depends on what other things use the stack space and how big the elements in the array are. But to be safe I recommend you do not store large arrays like that on the stack. You could use a vector instead.
Topic archived. No new replies allowed.