ftime()函数取得目前的时间和日期。

来源:互联网 发布:c语言判断大小端 编辑:程序博客网 时间:2024/04/29 09:37


 相关函数:time, ctime, gettimeofday

表头文件:#include <sys/timeb.h>
函数定义:int ftime(struct timeb *tp);
函数说明:ftime()将目前日期由tp所指的结构返回。tp结构定义:

struct   timeb{
       time_t   time;                      /* 为1970-01-01至今的秒数*/
       unsigned   short   millitm;   /* 千分之一秒即毫秒 */
       short   timezonel;               /* 为目前时区和Greenwich相差的时间,单位为分钟 */
       short   dstflag;                   /* 为日光节约时间的修正状态,如果为非0代表启用日光节约时间修正 */
};

返回值 :无论成功或失败都返回0

范例:
#include <sys/timeb.h>
main()
{
      struct   timeb   tp;
      ftime(&tp);
      printf("%d/n", tp.time);
}

原创粉丝点击