C语言中extern关键字的使用
C语言中extern关键字的使用,直接上代码。
file1.c文件
- #include<stdio.h>
- extern long power(int);
- int A = 2;
- int main()
- {
- int n = 10 ,total;
- total = power(n);
- printf("total = %d",total);
- return 0;
- }
file2.c文件
- extern A;
- long power(int n)
- {
- long total = 1;
- int i ;
- for(i = 1;i<=n;i++)
- {
- total = total * A;
- }
- return total;
- }
编译并运行
运行结果为1024
相关推荐
KilluaZoldyck 2020-01-10
electricperi 2019-08-02
qingsongzdq 2020-02-02
qingsongzdq 2020-01-17
lynjay 2020-01-09
lsfreeing 2020-01-09
beibeijia 2019-12-29
liuweinn 2010-09-21
Pipcie 2011-03-03
旭灿 2010-10-27
MYRENZHIBO 2019-08-28
一亩半分地 2011-10-18
徐建岗网络管理 2019-08-02
newdye 2011-01-10
makeWorks 2019-07-01
83457317 2011-02-16
Joymine 2012-08-29