The error is in the increment step. Consider:
Code:
void f(void)
{
int i ;
printf("n f() \n");
/* calling f function 5 times */
for (i=0;i<=5;i++) f() ;
}
When is i incremented in that function? Before or after f() is called again? Which one should it be?
Also, you are resetting i each time the function is called. I don't think that i can be local to a recursive function if you want it to hold increments between recursive calls.
Code:
int i = 0;
void f(void)
{
printf("n f() \n");
/* calling f function 5 times */
while (i <= 5)
{
i++;
f();
}
}
int main()
{
f();
}