其他分享
首页 > 其他分享> > C语言-自动变量和局部变量

C语言-自动变量和局部变量

作者:互联网

#include <stdio.h>
void auto_static (void)
{
int autoVar = 1;
static int staticVar = 1;
printf ("automatic = %i, static = %i\n", autoVar, staticVar);
++autoVar;
++staticVar;
}
int main (void)
{
int i;
void auto_static (void);
for (i = 0; i < 5; ++i)
auto_static ();

return 0;
}
//输出
//automatic = 1, static = 1
//automatic = 1, static = 2
//automatic = 1, static = 3
//automatic = 1, static = 4
//automatic = 1, static = 5

//--------------------------------
//Process exited after 0.1344 seconds with return value 0
//请按任意键继续. . .

标签:autoVar,变量,int,auto,void,局部变量,C语言,static,automatic
来源: https://www.cnblogs.com/Robin5067/p/12389801.html