【C】——extern

直接上例子:

1.c

1 #include<stdio.h>
2 int main()
3 {
4     extern int a;
5     a += 10;
6     printf("%d
",a);
7     text();
8     text2();
9 }

2.c

 1 int a = 10;
 2 void text()
 3 {
 4     printf("%d
",a);
 5 }
 6 
 7 void text2()
 8 {
 9     printf("%d
",a);
10 }

输出的结果是

20

20

20

原文地址:https://www.cnblogs.com/ngnetboy/p/3302262.html