Rat Chases Cheeze

// RAT CHASES ITS CHEESE
// You are given an N*M grid. Each cell (i,j) in the grid is either blocked, or empty. The rat can move from a position towards left, right, up or down on the grid.
// Initially rat is on the position (1,1). It wants to reach position (N,M) where it’s cheese is waiting for. There exits a unique path in the grid . Find that path and help the rat reach its cheese.

// Input Format:
// First line contains 2 integers N and M denoting the rows and columns in the grid.
// Next N line contains M characters each. An ‘X’ in position (i,j) denotes that the cell is blocked and ans ‘O’ denotes that the cell is empty.

I am using an int function instead of a bool function but still am facing a segmentation fault.

Code Link : https://ide.codingblocks.com/s/79789