435,064 Members | 1,542 Online
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

# recursion problem, getting "stack smashing detected", but i dont know why?? please ex

 P: 1 i m actually using recursion to find the different ways to reach a point in a 2d array from a fixed given point. i have to choose a start and target point randomly, i can only move right and down(i m choosing the start and end point according to that) i know that at every step i have to cll the same function 2 times, one for right and another time for moving down. further, i have to print the path only if it has more than 1 prime number, hence i have created a isprime function as well. there is no error in my code, but i m getting "stack smashing detected." problem what i have done in my code 1 i have made a n*n matrix with randomly filled values in it. 2 i have chosen the start and the target/end point. 3 i have made another matrix such that its start element is the start and the last element is the target/end 4 i have made an array int path[pnt+1], where pnt = 0 initially. 5 called a function move, with x,y(size of the array), array itself, pnt,i,j(i and j are the start index), i1,j1 (i1 and j1 are the target index), pnt, and finally path array here is my entire code with comments int prime(int a){ int i=2,flag=0; for(i;i1){ for(int b=0;b