输出窗口卡在黑屏上

Exp*_*ice 1 c recursion tail-recursion

#include<stdio.h>

int main()
{
    static int x;
    if(x == 10)
    printf("\n thanks...");
    x++;
    return (x=main());
}
Run Code Online (Sandbox Code Playgroud)

在运行程序时,它会卡在输出上:

谢谢...

这里有什么问题?

Sad*_*que 5

此递归没有终止条件.因此引导您 - a - StackOverflow.

也许这就是你想要尝试的:

#include<stdio.h>

int main(void)
{

    static int x;

if(x==10)
{
    printf("\n thanks...");
    return 0;  // --> Missing
}
x++;
return (x=main());
}
Run Code Online (Sandbox Code Playgroud)