_ftime

王朝百科·作者佚名  2012-04-12
窄屏简体版  字體: |||超大  

函数简介函数原型:

void _ftime(

struct _timeb *timeptr

);

头文件:

<sys/types.h> and <sys/timeb.h>

函数功能:

返回当前时间

参数说明:

struct _timeb {

time_t time;

unsigned short millitm;

short timezone;

short dstflag;

};

结构体定义于<sys/timeb.h>下

相关函数:

void _ftime32(

struct __timeb32 *timeptr

);

void _ftime64(

struct __timeb64 *timeptr

);

程序示例[1]

#include <stdio.h>

#include <sys/timeb.h>

#include <time.h>

int main( void )

{

struct _timeb timebuffer;

char timeline[26];

errno_t err;

time_t time1;

unsigned short millitm1;

short timezone1;

short dstflag1;

_ftime( &timebuffer ); // C4996

// Note: _ftime is deprecated; consider using _ftime_s instead

time1 = timebuffer.time;

millitm1 = timebuffer.millitm;

timezone1 = timebuffer.timezone;

dstflag1 = timebuffer.dstflag;

printf( "Seconds since midnight, January 1, 1970 (UTC): %I64d

",

time1);

printf( "Milliseconds: %d

", millitm1);

printf( "Minutes between UTC and local time: %d

", timezone1);

printf( "Daylight savings time flag (1 means Daylight time is in "

"effect): %d

", dstflag1);

err = ctime_s( timeline, 26, & ( timebuffer.time ) );

if (err)

{

printf("Invalid argument to ctime_s. ");

}

printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm,

&timeline[20] );

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航