gettimeofday windows inux下gettimeofday函数windows替换方法(详解)
人气:6想了解inux下gettimeofday函数windows替换方法(详解)的相关内容吗,在本文为您仔细讲解gettimeofday windows的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:gettimeofday,windows,下面大家一起来学习吧。
实例如下:
#include <time.h> #ifdef WIN32 # include <windows.h> #else # include <sys/time.h> #endif #ifdef WIN32 int gettimeofday(struct timeval *tp, void *tzp) { time_t clock; struct tm tm; SYSTEMTIME wtm; GetLocalTime(&wtm); tm.tm_year = wtm.wYear - 1900; tm.tm_mon = wtm.wMonth - 1; tm.tm_mday = wtm.wDay; tm.tm_hour = wtm.wHour; tm.tm_min = wtm.wMinute; tm.tm_sec = wtm.wSecond; tm. tm_isdst = -1; clock = mktime(&tm); tp->tv_sec = clock; tp->tv_usec = wtm.wMilliseconds * 1000; return (0); } #endif
以上就是小编为大家带来的inux下gettimeofday函数windows替换方法(详解)全部内容了,希望大家多多支持~
加载全部内容