| ftime() 原型如下: 
 [C++] 纯文本查看 复制代码 #include <sys/timeb.h>
       int ftime(struct timeb *tp);该函数将当前的时间日期由参数 tp 所指向的结构返回,struct timeb 结构体定义如下:
 
 [C++] 纯文本查看 复制代码   struct timeb {
               time_t         time;
               unsigned short millitm;
               short          timezone;
               short          dstflag;
           };其中,millitm 为千分之一秒,即毫秒;
 time 为自公元 1970 年 1 月 1 日至今的描述;
 timezone 为当前时区和格林威治相差的时间,单位为分钟;
 dstflag 为夏令时修正状态,如果该值非 0 则采用夏令时修正。
 
 函数不论失败或是成功都返回 0 。
 
 测试代码:
 
 [C++] 纯文本查看 复制代码 #include <stdio.h>
#include <sys/timeb.h>
int main()
{
        struct timeb tp;
        ftime(&tp);
        printf ("time: %d\n", tp.time);
        printf ("millitm: %d\n", tp.millitm);
        printf ("timezone: %d\n", tp.timezone);
        printf ("dstflag: %d\n", tp.dstflag);
        return 0;
}运行输出:
 [quote]./ftime
 time: 1324368235
 millitm: 682
 timezone: 0
 dstflag: 0[/mw_shl_code]
 |