当前位置:网站首页>12. Gettimeofday() and time()
12. Gettimeofday() and time()
2022-07-04 01:59:00 【666QAQ】
- gettimeofday()
gettimeofday()Can be found intvThe buffer pointed to is returned from Epoch(UTC 1970.1.1 00:00:00) Seconds since , Date stored intime_tVariable of type , This is a SUSv3 Defined integer type )
#include <sys/time.h>
int gettimeofday(struct timeval *tv, struct timezone*tz);
Returns 0 on success, or -1 on error
Parameters tv Is a pointer to the following data structure :
struct timeval{
time_t tv_sec; /*Seconds since 00:00:00, 1 Jan 1970 UTC*/
suseconds_t tv_sec; /*Addtional microseconds (long int)*/
}
Parameters tz Has been abandoned , Pass in on use NULL that will do .
2.time()time() The function also returns from Epoch Seconds since , This is due to historical reasons ,gettimeofday() More accurate , later time() It is right gettimeofday() Call to .
#include <time.h>
time_t time(time_t *timep);
Returns number of seconds since the Epoch or (time_t)-1 on error
time() Return the number of seconds in two ways , Parameters timep Or return value , But to avoid mistakes , Usually simply call :
time_t t = time(NULL);
Reference material :《Linuc/UNIX System programming manual 》
边栏推荐
- Ceramic metal crowns - current market situation and future development trend
- Hbuilder link Xiaoyao simulator
- Final consistency of MESI cache in CPU -- why does CPU need cache
- From the 18th line to the first line, the new story of the network security industry
- Méthode de calcul de la connexion MSSQL de la carte esp32c3
- Hunan University | robust Multi-Agent Reinforcement Learning in noisy environment
- Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
- How to delete MySQL components using xshell7?
- Openbionics robot project introduction | bciduino community finishing
- MySQL deadly serial question 2 -- are you familiar with MySQL index?
猜你喜欢

Introduction to superresolution

The automatic control system of pump station has powerful functions and diverse application scenarios

ES6 deletes an attribute in all array objects through map, deconstruction and extension operators

JVM performance tuning and practical basic theory - medium

Write the first CUDA program

Some other configurations on Huawei's spanning tree

Solution to the problem that jsp language cannot be recognized in idea

Small program graduation project based on wechat reservation small program graduation project opening report reference

2020-12-02 SSM advanced integration Shang Silicon Valley

Meta metauniverse female safety problems occur frequently, how to solve the relevant problems in the metauniverse?
随机推荐
Final consistency of MESI cache in CPU -- why does CPU need cache
Use classname to modify style properties
It's corrected. There's one missing < /script >, why doesn't the following template come out?
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
Trading software programming
JVM performance tuning and practical basic theory - medium
JVM performance tuning and practical basic theory - medium
Gnupg website
MySQL deadly serial question 2 -- are you familiar with MySQL index?
MySQL advanced (Advanced) SQL statement (I)
How can enterprises optimize the best cost of cloud computing?
What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
Maximum entropy model
Learn these super practical Google browser skills, girls casually flirt
A. ABC
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
Writeup (real questions and analysis of ciscn over the years) of the preliminary competition of national college students' information security competition
C import Xls data method summary I (upload files and create Workbooks)
Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
Servlet simple verification code generation