Difference between extern and global variables?
c, extern
Solution
extern doesn't actually create the variable though. It is like the forward declaration of a class, or the prototype of a function. Variable "i" at the starting creates a global integer named "i" which will exist in the current compilation unit, whereas "i" under the "int main" is a declaration that an integer named "i" exists somewhere in some compilation unit, and any uses of the name "i" refer to that variable.
Problem
``` #include <stdio.h> int i; int main() { extern int i; if (i == 0) printf("scope rules\n"); } ``` Output: scope rules How extern variable works here? Why there is no error like `Compile time error due to multiple declaration`