strcmp cannot convert 'std::string {aka std::basic_string}' to 'const char*'

strcmp is for C strings (null-terminated char*). string::compare is for C++ string S. If you really want to use strcmp with your std::string, you can use string::c_str() to get a pointer to the underlying C-string.code

if ( strcmp(stringOne.c_str()), stringTwo.c_str()  == 0 )

But of course, if you're using C++, you should actually use C++, and make use of std::string 's == overload.get

if (stringOne == stringTwo)

Quoted fromstring

相關文章
相關標籤/搜索