Getting Segmentation Fault?

Can you tell me why i am getting segmentation fault error.

Please tell me because of what mistake i am getting segmentation fault and how to avoid it because i got this problem in many codes.

here is my code: https://ide.codingblocks.com/s/218224

segmentation fault occur because it stuck in infinite recursion
first you move right and then from right you again move left and this cycle continues that’s why you are getting segmentation fault

to avoid this you have to make track of your path (grid[i][j]=1) and don’t move to those places where grid[i][j]==1

also there is no need of output array so can make changes on grid and in backtracking undo these changes

Please Correct my code .
Where it is wrong and share me the link


i have made required changes see this

Your Code gives wrong answer none of the testcases are passed.

Please provide correct code your code doesn’t pass the testcases

i think you are just copy pasting code
i have not make print function which you have to make which is very simple just printing a 2D array

make it at your own and understand code
just copy pasting will not help you

I have not copy pasted your code which is already wrong.

Please if you can tell so tell otherwise handle this to anyone else if you are not able to tell where i am going into infinite recursion and how to recover from that

code in which i make correction is passing all testcase after making print function which i left for you final code is:

it’s your choice you can repost your doubt

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.