我正在尝试学习递归。我不明白为什么下面的代码在无限循环中运行?
void myFunc(int n)
{
if(n==0)
return;
else
{
printf("%d\n",n);
myFunc(n--); //if I put n=n-1 before this line then it is running fine and will exit from the function .
printf("%d\n",n);
}
}
int main()
{
myFunc(4);
}