代码之家  ›  专栏  ›  技术社区  ›  Harish Boyina

静态在下面的代码中有什么不同?[已关闭]

c
  •  -2
  • Harish Boyina  · 技术社区  · 1 年前

    我刚刚为我的工作写了一些测试代码,在这里静态产生了一些影响。我不明白为什么是那样的?要知道确切的问题,请运行以下带有和不带有静态的代码。

    #include <stdio.h>
    void max(int x, int y);
    
    static inline void test(void)
    {
        printf("test is executing\n");
        return;
    }
    
    void max(int x, int y)
    {
        if(x > y)
            printf("x is greater than y\n");
        else if(x < y)
            printf("y is greater than x\n");
        else
            printf("x is equal to y\n");
    
        test();
    
        printf("I hope result is success\n");
    }
    
    int main(void)
    {
        int x = 5, y = 6;
        max(x,y);
        return 0;
    }
    

    我在当地试过,但没有成功。

    0 回复  |  直到 1 年前