相关疑难解决方法(0)

C中函数内部的静态变量

什么会被打印出来?6 6或6 7?为什么?

void foo()
{
    static int x = 5;
    x++;
    printf("%d", x);
}

int main()
{
    foo();
    foo();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c static

105
推荐指数
6
解决办法
16万
查看次数

标签 统计

c ×1

static ×1