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*)'
-
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!
-
@Lian-ZhiYang have you tried using the std::string c_str() method to convert std::string to const char*?
See here. -
yes,I have tried the method
-
@Lian-ZhiYang Can you show a few lines of your code?
-
-
@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.
-
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 ;) )