#include<stdio.h>
int recursive(int f,int g){
static int a;;
static int b;
int c = 100;
a = f;
b = g;
if(c != 105){
a++;
b++;
c++;
recursive(a,b);
}
printf("\n a : %d b : %d \n",a,b);
return 0;
}
int main(){
int a = 10;
int b = 1;
recursive(a,b);
}
In the above example, a recursive program gives segfault. It was not possible to understand why segfault happens because there are no pointers.
source
share