---
title: "time,gettimeofday,clock_gettime,_ftime "
author: "andy136566"
date: "2011-08-14T21:08:31Z"
tags: []
categories: ["编程语言"]
slug: "time-gettimeofday-clock-gettime-ftime"
draft: false
lastmod: "2011-10-01T14:29:37Z"
id: 1149062
url: "https://andy136566.iteye.com/blog/1149062"
---

[http://blog.csdn.net/sunlylorn/article/details/6313278](http://blog.csdn.net/sunlylorn/article/details/6313278)

 

 

 

 

 

 

 

 

 

 

[view plain](http://blog.csdn.net/sunlylorn/article/details/6313278 "view plain")[copy to clipboard](http://blog.csdn.net/sunlylorn/article/details/6313278 "copy to clipboard")[print](http://blog.csdn.net/sunlylorn/article/details/6313278 "print")[?](http://blog.csdn.net/sunlylorn/article/details/6313278 "?")

01. \_ftime()提供毫秒级的精确度
02. 1、头文件 &lt;sys/types.h&gt; and &lt;sys/timeb.h&gt;
03. 2、函数原型
04. **void** \_ftime(**struct** \_timeb \*timeptr);
05. 参数说明：
06. **struct** \_timeb
07. {
08. time\_t time;
09. unsigned **short** millitm;
10. **short** timezone;
11. **short** dstflag;
12. };
13. #include &lt;stdio.h&gt;
14. #include &lt;sys/timeb.h&gt;
15. #include &lt;time.h&gt;
16. **void** main( **void** )
17. {
18. **struct** \_timeb timebuffer;
19. **char** \*timeline;
20. \_ftime( &timebuffer );
21. timeline = ctime( & ( timebuffer.time ) );
22. printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline\[20] );
23. }