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 对转岗同学祝福语简短