Real example of extern variable
I want to understand the external variable by doing an experiment I searched on the internet and found this link External variable - Wikipedia
Now I made two files, file1.c and file2.c
Code:
//GCC compiler
#include<stdio.h>
int Global_Variable;
// Function prototype
void SomeFunction(void);
int main(void)
{
Global_Variable = 1;
SomeFunction();
printf ("%d", Global_Variable);
return 0;
}
Code:
extern int Global_Variable;
// Function header (definition)
void SomeFunction(void) {
++Global_Variable;
}
if I use extern keyword result would be 2 and If I remove extern result would be 1
I do not understand how this work