weixin_38707719
weixin_38707719
2017-05-09 01:33

菜鸟提问,C++如何获取系统时间

  • c++

下面这段代码是自动写入一个指定时间,想知道调用那个函数可以自动获取系统时间?
int year, month, day, hour, minute,second;

struct tm tm_;
sscanf("2017-05-04 20:22:11","%d-%d-%d %d:%d:%d", &year, &month, &day, &hour, &minute, &second);

tm_.tm_year = year-1900;

tm_.tm_mon = month-1;

tm_.tm_mday = day;

tm_.tm_hour = hour;

tm_.tm_min = minute;

tm_.tm_sec = second;

tm_.tm_isdst = 0;

time_t t = mktime(&tm_);

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答