当前位置:网站首页>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 》
边栏推荐
- The automatic control system of pump station has powerful functions and diverse application scenarios
- Mobile phone battery - current market situation and future development trend
- Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
- String & memory function (detailed explanation)
- Magical usage of edge browser (highly recommended by program ape and student party)
- Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
- Feign implements dynamic URL
- It's corrected. There's one missing < /script >, why doesn't the following template come out?
- C import Xls data method summary III (processing data in datatable)
- Huawei BFD and NQA
猜你喜欢

Huawei cloud micro certification Huawei cloud computing service practice has been stable

Life cycle of instance variables, static variables and local variables

How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #

Take you to master the formatter of visual studio code

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

Magical usage of edge browser (highly recommended by program ape and student party)

Gee: create a new feature and set corresponding attributes

Solution to the problem that jsp language cannot be recognized in idea
![Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]](/img/8b/ff062f34d36e1caa9909c8ab431daf.jpg)
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]

Make drop-down menu
随机推荐
In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
LeetCode226. Flip binary tree
Openbionics robot project introduction | bciduino community finishing
Bacteriostatic circle scanning correction template
Do you know the eight signs of a team becoming agile?
Use classname to modify style properties
Small program graduation project based on wechat reservation small program graduation project opening report reference
What are the advantages and disadvantages of data center agents?
Writeup (real questions and analysis of ciscn over the years) of the preliminary competition of national college students' information security competition
TP5 automatic registration hook mechanism hook extension, with a complete case
Description of setting items of Jerry [chapter]
Solution to the problem that jsp language cannot be recognized in idea
Luogu p1309 Swiss wheel
51 single chip microcomputer timer 2 is used as serial port
Software product download collection
Conditional test, if, case conditional test statements of shell script
Huawei BFD and NQA
C import Xls data method summary IV (upload file de duplication and database data De duplication)
From the 18th line to the first line, the new story of the network security industry
It's corrected. There's one missing < /script >, why doesn't the following template come out?