printf("value of var from foo: %d\n", foo());
printf("accessing var directly:%d\n ", var);
int var; /*global to this file and can be extern-ed by another file*/
gcc -o test test.c test1.c
~/test $ ./test
value of var from foo: 1
accessing var directly:1
In the case of extern"C", it specifies that the identifier does/will have C linkage. In other words, it is used to suppress C++ name mangling, which enables a C++ function to be called from C or, the other way around, a C function to be called in C++.