#include<stdio.h>
void trystat(void);
int main (void)
{
int count;
for (count=1; count<=3; count++)
{
printf ("Here comes iteration%d :\n",count);
trystat( );
}
}
void trystat(void)
{
int fade = 1;
static int stay =1; //靜態變量,只進行一次初始化,所以從1開始
printf ("fade = %d and stay= %d \n",fade++,stay++);
}
Here comes iteration 1 :
fade = 1 and stay = 1
Here comes iteration 2 :
fade = 1 and stay = 2
Here comes iteration 3 :
fade = 1 and stay = 3
|