Unsolved Can anybody explain me below statement ?
I want to understand the below statement in terms of programming can any body help me ?
no need to extract a std::string from a std::stringstream when its only use is to get its content via c_str()
JoeCFD last edited by JoeCFD
Something like this:
std::stringstream ss("this is a string\n");
const std::string& tmp = ss.str();
const char* cstr = tmp.c_str();
std::cout << " ====== " << cstr << std::endl;
It may mean that you do not need a copy of the string when you need only c_str().
@JoeCFD so what exactly i need to write instead of it. can you give example.