我需要一个带有时间戳(以毫秒为单位)的字符串。
我通过这种方式得到了毫秒(在 stackoverflow 上查找之后):
milliseconds ms = duration_cast< milliseconds >(
system_clock::now().time_since_epoch()
);
现在我必须像这样连接它:
string = "something " + ms + " something else";
有什么帮助吗?
先感谢您 :)
你需要一种转换的方式ms
成字符串。该标准有std::to_string()但这不会直接与持续时间一起工作。将持续时间转换为整数类型to_string()
可以使用你需要使用的count()功能
string = "something " + std::to_string(ms.count()) + " something else";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)