示例
//Visual Studio中加上这句才可以使用scanf()
//否则只能使用scanf_s()
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//malloc()、free()
#include <stdlib.h>
#include <time.h>
void trystat(void);
//argc: 参数个数 argv[]: 参数数组
//int main(int argc, char **argv)
int main(int argc, char *argv[])
{
int count;
for (count = 1; count <= 3; count++)
{
printf("Here comes iteration %d:\n", count);
trystat();
}
system("pause");
return 0;
}
void trystat()
{
int fade = 1;
//声明块作用域的静态变量,局部静态变量又叫内部静态存储类别
//这里的内部指函数内部,而非内部链接。
//只在编译时初始化一次,这条声明并未在运行时执行。
static int stay = 1;//默认初始化为0
printf("fade=%d and stay=%d\n", fade++, stay++);
}
运行测试