0

Got error:(no suitable conversion function in c++)

I got this error on line 45: no suitable conversion function from "std::string" to "const char *" exists This is my code: https://code.sololearn.com/cbf81a6C691e

1st Aug 2020, 4:13 AM
Janak Sharma
Janak Sharma - avatar
5 Respostas
+ 4
Compare by using overloaded comparison operator instead. if(ap == "AM")
1st Aug 2020, 4:25 AM
Ipang
+ 2
I am not 100% sure but I think we cannot compare string variable with strcmp. Strcmp is for comapring const char* variable not string variable. This might be useful: http://www.cplusplus.com/reference/string/string/compare/
1st Aug 2020, 4:24 AM
Adnan Chowdhury
Adnan Chowdhury - avatar
+ 1
Ipang thank you it worked
1st Aug 2020, 9:27 AM
Janak Sharma
Janak Sharma - avatar
+ 1
No problem Janak Sharma 👌
1st Aug 2020, 10:03 AM
Ipang
0
Adnan Chowdhury thank you
1st Aug 2020, 11:37 AM
Janak Sharma
Janak Sharma - avatar