There are 2 source code file:
def.c
Code:
/*just define the i*/
int i = 3;
print_i.c
Code:
/*display the i*/
#include<stdio.h>
void print_i(void){
int i;
printf("The number is %d\n",i);
}
main.c
Code:
#include<stdio.h>
int main(void){
print_i();
return 0;
}
As I konw there is something wrong in my code, the varible i is defined in the def.c ,and used in the print_i.c . So I must define the i with 'extern', it means I should use "extern int i" replace the "int i" in the print_i.c. But I haven't make this replacement, the code can run successful.
I want to know is the 'extern' be indispensable to this program?