64,685
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <sys/time.h>
int main(int argc, char *argv[]) {
struct timeval tv;
if (gettimeofday(&tv, NULL) == 0)
{
time_t s = tv.tv_sec *1000;
time_t c = tv.tv_usec / 1000;
time_t time = s + c;
time_t time = s + c;
printf("%u:%u\n", tv.tv_sec, tv.tv_usec);
printf("%u:%u\n%u\n",s,c,time);
}
return 0;
}
int64_t s = (int64_t) tv.tv_sec * 1000;
int64_t c = tv.tv_usec / 1000;
int64_t time = s + c;
printf("%u:%u\n", tv.tv_sec, tv.tv_usec);
printf("%llu\n",time);
cout << time;
#include <stdio.h>
#include <sys/time.h>
int main(int argc, char *argv[]) {
struct timeval tv;
if (gettimeofday(&tv, NULL) == 0)
{
long long s = tv.tv_sec;
s *= 1000;
time_t c = tv.tv_usec / 1000;
time_t time = s + c;
printf("%u:%u\n", tv.tv_sec, tv.tv_usec);
printf("%llu:%u\n%u\n",s,c,time);
}
return 0;
}