set a flag, 使得某部分程序只执行一次。
// *********************************************
// @brief : the code for c experience
// @author : mas
// *********************************************
#include <stdio.h>
int once(int testflag)
{
if(testflag==0)
{
return 1;
}
printf("the section operation once!"); // the section operation once!
testflag=0;
}
int main(void)
{
int testflag=1;
while(1)
{
once(testflag);
}
getchar();
return 0;
}