正在查找具有tm以外的成员对象的另一个时间结构
looking for another time structure with member objects other than tm
成员tm_mon
在struct 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];
相关文章:
- 将另一个类的对象传递到当前类C++的构造函数中(不是成员初始化)
- 复制赋值函数如何访问另一个对象的私有成员(Stroustroup 原则和实践书)?
- 在C++中,是否可以"overload"作为另一个类成员的对象?
- C++ - 非静态 void* 成员,指向具有相同地址但不同值的不同对象的另一个非静态成员
- C++入门5版:使用get成员初始化另一个与shared_ptr无关的对象
- 在成员变量在另一个文件中发生更改后,调用与初始化对象分开的函数
- 在另一个 QThread 上运行成员方法时,无法将事件发送到其他线程拥有的对象
- 编译问题 C++ 同时,尝试通过调用另一个对象中的成员函数来创建 std:: 线程
- 为什么在对象引用恒定时允许更改为另一个类的指针的成员变量
- 如果类成员来自另一个类,如何完成构造函数
- 无法将类对象创建为另一个类的成员
- 使用没有对象的另一个类的成员函数,避免静态
- 静态const数据成员在另一个文件中定义
- 将一个类的对象声明为另一个类(C++)的成员
- 使用从另一个类继承的类的对象初始化成员对象
- C++ Qt4.8 :: 将对象传递给另一个类 - 成员访问不完整类型错误
- 类成员是另一个类的对象
- 从std::向量中的每个结构中选择一个成员到另一个向量中
- 删除对象(另一个..)时双重释放或损坏
- 结构指针成员指向另一个结构会导致分段错误(C/C++)