c++ - 为 std::put_time 调试断言 "Invalid format directive"

标签 c++ visual-studio-2012 c++11

我正在学习使用 C++11 chrono,并尝试输出时间。 Other SO questions显示一些代码示例,例如

std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now - std::chrono::hours(24));
std::cout  << std::put_time(std::localtime(&now_c), "%F %T") << '\n';

当我在 VS2012 上调试运行它时,我得到一个调试断言,声称我使用了“无效的格式指令”。

如果我使用 std::strftime,也会发生同样的情况。我假设 Microsoft 不支持 %F%T

最佳答案

纯粹是因为微软不支持%F和%T

关于c++ - 为 std::put_time 调试断言 "Invalid format directive",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16980397/

相关文章:

c++ - 使用 boost::signals2 编译时间非常慢

c++ - 如何在 C++11 中输出枚举类的值

c++ - 如何检查两个元组的所有成员是否不同?

c++ - 将绝对地址转换为指针变量的现代 C++ 方法是什么?

c++ - 当显示为对话框时,派生的小部件不以父级为中心

c++ - 如何为无序映射 C++14 包含更好的位混合器

c# - 无法访问 asp :TextBox tag from the C# file : the name 'txtUsername' does not exist in the current context

c# - 命名空间错误 OfficeOpenXML EPPlus

c++ - OpenGL 减慢 5k 点

c++ - VTK Python Wrapper - 导出曲面图