C语言中的extern存储类是什么?!
C语言中有四个存储类,如下所示-
汽车
外部的
静止的
登记
全局变量/外部变量
关键字是extern。这些变量在块外声明。
范围-全局变量的范围在整个程序中可用。
默认值为零。
算法
算法如下-
START Step 1: Declare and initialized extern variable Step 2: Declare and initialized int variable a=3 Step 3: Print a Step 4: Call function step 5 Step 5: Called function Print a (takes the value of extern variable)
示例
以下是外部存储类的C程序-
extern int a =5; /* this ‘a’ is available entire program */
main ( ){
int a = 3; /* this ‘a' is valid only in main */
printf ("%d",a);
fun ( );
}
fun ( ){
printf ("%d", a);
}输出结果输出如下-
3 1
考虑另一个用于外部存储类的程序-
示例
External.h extern int a=14; extern int b=8; externstorage.c file #include输出结果#include "External.h" int main(){ int sub = a-b; printf("%d -%d = %d ", a, b, sub); return 0; }
输出如下-
a-b=6
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短