c语言-倒计时

#include
#include
#include


int countDown()
{
	int hour,min,sec;//
	int hour_h,min_m,sec_s;//accept time
	int i,j,k;
	time_t nowtime;//time_t equals long
	struct tm*timeinfo;//time structure pointer variable
	time(&nowtime);//get time
	timeinfo=localtime(&nowtime);//turn into local time
	hour=timeinfo->tm_hour;//the hour variable in tm  struct
	min=timeinfo->tm_min;//
	sec=timeinfo->tm_sec;//
	hour_h=23-hour;
	min_m=59-min;
	sec_s=59-sec;
	printf("%02d:%02d:%02d",hour_h,min_m,sec_s);
	printf("Count Down :\n");
	for(i=hour_h;i>=0;i--)
	{
		for(j=min_m;j>=0;j--)
		{
			for(k=sec_s;k>=0;k--)
			{
				printf("\r%02d:%02d:%02d",i,j,k);
				Sleep(1000);
			}
			sec_s=59;
		}
		min_m=59;
	}
		return 0;
	
	}
	//About the time_t error
	int countDown2()
	{
		time_t biggest=0x7FFFFFFF;
		printf("biggest=%s\n",asctime(localtime(&biggest)));
		
		return 0;
	}
	
	int main()
	{
	countDown();	
	countDown2();	
		
		
		
		return 0;
	}

c语言-倒计时_第1张图片

你可能感兴趣的:(C)