I am reading a table of numbers into an array then calling a recursive function. My program works great for small numbers like 4, 5, 6 but when I read in the 22 by 22 table, I get a segmentation fault:
"unhandled exception: stack overflow"
Why does the program work for small numbers and not large numbers and how do I fix it?
The problem happens in the following function:
void trace(int count, int loc, bool marker, int col[COLS],
int row[ROWS], int table[ROWS][COLS], int size)
{
count++;
if(marker)
{
for(int x = 0; x < size; x++)
{
if(table[loc][x] == 1)
{
col[x] = count;
trace(count, x, false, col, row, table, size);
}
}
}
else
{
for(int x = 0; x < size; x++)
{
if(table[x][loc] == -1)
{
row[x] = count;
trace(count, x, true, col, row, table, size);
}
}
}
return;
}
by: peterdownesPosted on 2002-10-24 at 21:07:30ID: 7367993
Could you show us where you call this.