采用ctime库获得系统日期和时间,并将系统时间以tm结构接收。
#include#include using namespace std; int main() { time_t now_time; now_time = time(NULL); tm *ltm = new tm; localtime_s(ltm,&now_time); cout << ltm->tm_hour << ":" << ltm->tm_min << ":" << ltm->tm_sec << endl; delete ltm; system("pause"); return 0; }



