mercredi 17 février 2021

time conversion fails on Linux

ALL,

pcap_pkthdr pkthdr;
time_t nowtime = pkthdr->ts.tv_sec;
char tmbuf[64];
struct tm *nowtm = localtime( nowtime );
strftime( tmbuf, sizeof( tmbuf ), "%Y-%m-%d %H:%M:%S", nowtm );

Trying to compile this code using gcc with C++11, I am getting:

error: invalid conversion from 'time_t {aka long int}' to 'const time_t* {aka const long int*}' [-fpermissive]
                         struct tm *nowtm = localtime( nowtime );
                                                               ^

What is wrong? Why am I getting an error?

Aucun commentaire:

Enregistrer un commentaire