gpt4 book ai didi

c++ - get_time 未按预期运行

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:59:22 24 4
gpt4 key购买 nike

我在尝试使用 put_timeget_time 函数时遇到了一些问题。

我拿了这段代码:

#include <iostream>
#include <sstream>
#include <locale>
#include <iomanip>

int main()
{
std::tm t = {};
std::istringstream ss("2011-Februar-18 23:12:34");
ss.imbue(std::locale("de_DE.utf-8"));
ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S");

if (ss.fail()) {
std::cout << "Parse failed\n";
} else {
std::cout << std::put_time(&t, "%c") << '\n';
}
}

来自 here .但是,当同时使用 gcc 版本 8.8.1 和 clang 版本 6.0.0 进行编译时,我得到解析失败,即使 cppreference 中的示例应该可以使用 clang。

谁能告诉我哪里出了问题?

最佳答案

OP给的链接里说的很清楚

Example

note: choose clang to observe the output. libstdc++ does notcorrectly implement the %b specifier: bug 78714

关于c++ - get_time 未按预期运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50838177/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com