Hello,
i have 2 strings, str1 and str2, and i use the strcat() function :
strcat(str1 , str2);
but i receive the error :
error: cannot convert `std::string' to `char*' for argument `1' to `char* strcat(char*, const char*)' |
any idea how to solve it ?
Thanks .
Last edited on
strcat(str1.c_str() , str2.c_str());
But actually if you have C++ string, you can just use str1 + str2 can already. No need to use C functions like strcat, strcmp etc.
In case you want strcat again try below
strcat(const_cast<char *>(str1.c_str()) , const_cast<char *>(str2.c_str()) );