c - What does it mean to declare variables as static in a function? -
i looking function audio effect, , found 1 written in c.
inside function, variables declared static. confused, thought static means these variables not visibles other files. since declared inside inside function, not visible other files.
what missing ?
static
inside function means hold value next time function called.
for example,
int foo() { static int = 0; printf("%d\n", i); i++; } int main() { foo(); // prints 0 foo(); // prints 1 }
Comments
Post a Comment