gpt4 book ai didi

c++ - std::get_time 中日期时间的格式

转载 作者:行者123 更新时间:2023-11-30 05:05:06 24 4
gpt4 key购买 nike

<分区>

如何修改此代码以便能够将此字符串“22/12/2016 01:12:10”正确解析为 date_time 变量?

struct tm date_time = {};
std::wstring dateTimeFormat{ L"%d/%m/%Y %H:%M:%S" };
std::istringstream ss("22/12/2016 01:12:10");
ss >> std::get_time(&date_time, dateTimeFormat.c_str());


1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools
\msvc\14.12.25827\include\iomanip(190): error C2338: wrong character type for
get_time
1>c:\...\procedure.cpp(70): note: see reference to function template
instantiation 'std::basic_istream<char,std::char_traits<char>> &std::operator
>><char,std::char_traits<char>,_Elem>(std::basic_istream<char,std::char_traits<char>>
&,const std::_Timeobj<_Elem,tm *> &)' being compiled
1> with
1> [
1> _Elem=wchar_t
1> ]
1>Done building project "projectname" -- FAILED.

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