What does “static” mean in C?

后端 未结 19 1912
误落风尘
误落风尘 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:37

    Short answer ... it depends.

    1. Static defined local variables do not lose their value between function calls. In other words they are global variables, but scoped to the local function they are defined in.

    2. Static global variables are not visible outside of the C file they are defined in.

    3. Static functions are not visible outside of the C file they are defined in.

提交回复
热议问题