Rat chases its cheese- no output

i have dry run my code…according to me it should complete its function calls…but when all the conditions return false its not moving forward and therefore i am not getting an output. pls check my code.

Your code is producing run time error. Plz use array in your code instead of pointers. In your solution you also need to maintain a visited array just to check if that path is already visited earlier or not,
if(visited[i][j])
{
return false;
}
Then u need to maintain 4 variables,
bool rightSuccess,downSuccess,topSuccess,leftSuccess;
And before you traverse in any direction, make sure to check the similar condition

if(visited[i][j+1]==false && solution[i+1][j]==0)
{
downSuccess=ratmaze(maze,solution,i+1,j,N,M);
}

but I have checked in my issafe function if its visited or not

I have modified your code, there were few errors, Plz refer to this code, in case you didnt understood the changes, you can request for chat option,

what is the use of visited array in this if we already have a solution array.

Basically, in the question you are supposed to print a single path which is rightmost, thats why if we wont use visited array, then all the paths will be printed, thats why we used visited array.

for me it worked without visited …i have just compared from the solution array

Yes, your code will be submitted, but in such kind of questions, it is advisable to use visited array so that no of computations reduces