struct tm *currtime;
long tloc;
time(&tloc);
// get time in seconds since epoch
currtime = localtime(&tloc);
// convert seconds to date structure
while (currtime->tm_year < 100) // loop until ntp time is set (year
// >= 2000){
sleep(15);
time(&tloc);
currtime = localtime(&tloc);
}
本文介绍了一个使用C语言处理时间的示例程序。该程序通过获取当前时间并将其转换为日期结构来演示如何检查年份是否大于等于2000。通过循环等待直到获取到有效的年份。
1680

被折叠的 条评论
为什么被折叠?



