I have craeted following kind of function in a class:
void SetStr(string& s1, string& s2)
{
const char* s =(s1+s2).c_str();
cout<<s<<endl;
}
On calling it from main nothing is getting printed on console. While the following function works:
void SetStr(string& s1, string& s2)
{
cout<<(s1+s2).c_str()<<endl;
}
Can someone please tell me what is the problem.
Thank you.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)