Thursday, 12 September 2013

Return function returning to main instead of caller

Return function returning to main instead of caller

just wondering...
void mazeTraversal(char maze[12][12], int x, int y)
{
if (maze[x + 1][y] == '.')
mazeTraversal(maze, ++x, y);
if (maze[x][y + 1] == '.')
mazeTraversal(maze, x, ++y);
if (maze[x - 1][y] == '.')
mazeTraversal(maze, --x, y);
if (maze[x][y - 1] == '.')
mazeTraversal(maze, x, --y);
return;
}
when i hit a dead end, should i revert to the previous instance of the
call, instead of going straight back to the main function? If I have
something wrong please tell me.

No comments:

Post a Comment