Skip to content

Latest commit

 

History

History
35 lines (32 loc) · 354 Bytes

41.md

File metadata and controls

35 lines (32 loc) · 354 Bytes

题目:学习static定义静态变量的用法。

#include<stdio.h>

void f()
{
	int i = 0;
	static int si = 0;
	printf("i=%d\n", i);
	printf("static si = %d\n", si);
	i++;
	si++;
}

int main()
{
	for (int i = 0; i < 4; ++i)
	{
		f();
	}

	return 0;
}

结果:

i=0
static si = 0
i=0
static si = 1
i=0
static si = 2
i=0
static si = 3