What is the difference between static int a and int a?

c

Solution

A `static` global variable is local to the translation unit it is defined in. So, if you define `static int a;` in two different translation units, this will create two independent variables. If you define a non-static global variable `int b;` in two translation units, you will experience a linker error (but you can use `extern int b;` in one of the two translation units to tell the linker that it should use the global variable from the other translation unit).

Problem

Possible Duplicate: Difference between 'global' and 'static global' What is the difference between statements 1 and 2 :- ``` #include <stdio.h> //In the global declaration area static int a; // 1. int b; // 2. ``` Thanks for help.

Original source

Related problems