how to prevent stack-overflow?
hi all,
I write some codes based in recursive method(or some similar methods),eg. in maze-searching... they work ,but sometimes cause stack-overflow.
i try to write a function to prevent this, but i don't know if it works...
1: use a varible size to count the number of recursion times
2: after each call, check size using following code
Code:
.....
if (size == 4*BUFSIZ)//prevent stack overflow after too many setps
{
printf("\nMaze too large,Stack overflowed!");
exit(0);
}
...
the problem is that i'm not clear how many steps can a system stack hold...
plz help with this, thanks