- 5
- 0
- 约2.43千字
- 约 21页
- 2017-04-23 发布于四川
- 举报
第十三讲变量的存储类别
第13讲 变量的存储类型、内部和外部函数;数据类型:指变量的名称、类型、取值范围和占据存贮空间的大小。如 整型,实型,字符型等。;1、 自动变量;2、外部变量 ;C语言规定:
1)对共用的外部变量可以在任一源文件中定义一次,其他源文件中用extern对其声明后,即可使用。;#include stdio.h
int max( int a, int b )
{ int c ;
c=ab?a:b ;
return c;
}
void main( )
{ extern x, y ; /* 声明外部变量*/
printf(%d\n, max(x, y));
}
int x=12, y=-8; /* 定义外部变量 */;// 文件1:f1.cpp
#include stdio.h
#include c:\user\f2.c
int x; //定义外部变量
main( )
{ int a=3,b=4;
x=a;
printf(%d\n, pow1(b) ); };3、静态变量;#include stdio.h
void f (int n)
{ auto int s=10; //auto可省略
s=s+1;
printf(s=%d\n, s);
}
void main()
{ int
原创力文档

文档评论(0)