2008年3月1日 星期六

小型專案實作-定時關機程式

#include
#include
#include

int main(){
static int usr_sec = -1;
time_t t;
struct tm* plt;

while(1){
time(&t);
plt = localtime(&t);

if(usr_sec!=plt->tm_sec){
printf("%d/%d/%d %2d:%2d:%2d\r", (plt->tm_year+1900), (plt->tm_mon+1), plt->tm_mday, plt->tm_hour, plt->tm_min, plt->tm_sec);
usr_sec = plt->tm_sec;
}
}
system("pause");
}
/*
struct tm
{
int tm_sec; // seconds after the minute [0,61]
int tm_min; // minutes after the hour [0,59]
int tm_hour; // hour of the day [0,23]
int tm_mday; // day of the month [1,31]
int tm_mon; // month of the year [0,11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday [0,6]
int tm_yday; // day of the year [0,365]
int tm_isdst; // Daylight Saving Time flag
};
*/

ps. 排版亂了....囧rz
未完成.....佔用系統資源過大

沒有留言: