Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

What does “static” mean in C?

I've seen the word static utilized in better places in C code; is this like a static function/class in C# (where the execution is shared across objects)?
by

2 Answers

RoliMishra
We can use static 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.
MounikaDasa
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.

Login / Signup to Answer the Question.