har*_*ari 4 c freebsd systemtime processing-efficiency
用C语言获取当前时间/日期/日/年的最有效方法是什么?由于我必须多次执行,我需要一种真正有效的方法.我在freeBSD上.
提前致谢.
/* ctime example */
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
time ( &rawtime );
printf ( "The current local time is: %s", ctime (&rawtime) );
return 0;
}
Run Code Online (Sandbox Code Playgroud)
标准C只提供一种获取时间的方法 - time()可以用localtime()或转换为时间/日期/年份gmtime().如此简单,这必须是最有效的方式.
任何其他方法都是特定于操作系统的,您还没有告诉我们您正在使用的操作系统.