how to solve the problem about:cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'char* strptime(const char*, const char*, tm*)'
-
wrote on 27 Feb 2021, 15:00 last edited by
I wrote the strptime function in Windows 10 environment to convert a string to a time,but when I build the code ,there is the problem:cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'char* strptime(const char*, const char*, tm*)'.How to solve the problem?Thank you!
-
I wrote the strptime function in Windows 10 environment to convert a string to a time,but when I build the code ,there is the problem:cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'char* strptime(const char*, const char*, tm*)'.How to solve the problem?Thank you!
wrote on 27 Feb 2021, 15:37 last edited by@Lian-ZhiYang have you tried using the std::string c_str() method to convert std::string to const char*?
See here. -
wrote on 27 Feb 2021, 16:04 last edited by
yes,I have tried the method
-
yes,I have tried the method
wrote on 27 Feb 2021, 16:06 last edited by@Lian-ZhiYang Can you show a few lines of your code?
-
wrote on 27 Feb 2021, 16:25 last edited by
-
wrote on 27 Feb 2021, 16:34 last edited by
@Lian-ZhiYang it looks like you've fixed the error in the 2nd strptime() by using c_str() (line 86), but not in the 1st (line 77). You need to use c_str() in line 77 as well.
-
wrote on 27 Feb 2021, 16:51 last edited by
Thank you very much! I have solved my problem by your way!
-
Why not use QDateTime (when you already ask a c++ only question in a Qt forum ;) )
2/8