正在查找具有tm以外的成员对象的另一个时间结构

looking for another time structure with member objects other than tm

本文关键字:成员对象 另一个 时间 结构 查找 tm      更新时间:2023-10-16

成员tm_monstruct tm中存储为整数。我正在寻找另一个存储月份实际名称的时间stuct。我可以使用获得用户友好的格式

ctime();

但是我如何选择性地只输出一个月呢?

有一个类似的数组

string Months[] = {"January", "February", ... };

然后当你想打印使用时,

time_t t = time(0);   // get time now
struct tm * now = localtime( & t );
cout << Months[now-> tm_mon];