What does “static” mean in C?

后端 未结 19 1959
误落风尘
误落风尘 2020-11-21 05:18

I\'ve seen the word static used in different places in C code; is this like a static function/class in C# (where the implementation is shared across objects)?

19条回答
  •  一向
    一向 (楼主)
    2020-11-21 05:20

    There is one more use not covered here, and that is as part of an array type declaration as an argument to a function:

    int someFunction(char arg[static 10])
    {
        ...
    }
    

    In this context, this specifies that arguments passed to this function must be an array of type char with at least 10 elements in it. For more info see my question here.

提交回复
热议问题