求一个C++的获取计算机时间的库函数?

来源:百度知道 编辑:UC知道 时间:2024/06/08 02:46:49
在C++的库函数中有一个获取计算机时钟时间的函数,麻烦给出这个函数的接口和返回值类型!

#include <time.h>
time_t ltime;
time( <ime );
这样就可以了, 下面是示例代码,够详细了吧...

// crt_times.c
// compile with: /W3
// This program demonstrates these time and date functions:
// time _ftime ctime_s asctime_s
// _localtime64_s _gmtime64_s mktime _tzset
// _strtime_s _strdate_s strftime
//
// Also the global variable:
// _tzname
//

#include <time.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <string.h>

int main()
{
char tmpbuf[128], timebuf[26], ampm[] = "AM";
time_t ltime;
struct _timeb tstruct;
struct tm today, gmt, xmas = { 0, 0, 12, 25, 11, 93 };
errno_t err;

// Set time zone from TZ environment variable. If TZ is not set,
// the operating system is queried to obtain the default