What does static variable mean

Q

What does static variable mean?

✍: FYIcenter

A

There are 3 main uses for static variables:

  • If you declare within a function, it retains the value between function calls.
  • If it is declared for a function name, by default function is extern. So it will be visible from other files. If the function declaration is as static, it is invisible for the outer files.
  • Static for global variables. By default we can use the global variables from outside files. If it is static global, that variable is limitied to with in the file.

2007-02-26, 6771👍, 0💬