If I have the following two functions
std::string foo1()
{
std::string temp;
...
return temp;
}
and
const char* foo2()
{
std::string temp;
...
return temp.c_str();
}
and a function that takes a const char* as input;
void bar(const char* input) { ... }
Which one is safer to do:
bar(foo1().c_str());
or
bar(foo2());
If all I want to do is pass a string as an input to bar and then not care about the return value of either foo
function will it actually matter?