Kindly tell how to stop after printing one way of path

MY CODE IS PRINTING ALL THE CASES AS IN VIDEO

KINDLY SEND THE CODE AFTER EDITING ASAP

You can maintain a visited array as, int visited[1000][1000]… and then before traversing, check if you have already visited that path before or not… This should be done to print unique path…

sol[i][j]=1;
visited[i][j]=1;
if(j+1<=M && !visited[i][j+1])
{
bool rightSuccess=ratInmaze(maze,sol,i,j+1,m,n);
if(rightSuccess==true)
{
return true;
}
}
if(i+1<=N && !visited[i+1][j])
{
bool downSuccess=ratInmaze(maze,sol,i+1,j,m,n);
if(downSuccess==true)
{
return true;
}
}