Hi,
while I know that returning pointers to stack/local/automatic variables is wrong:
I'm not sure how correct is this:Code:int *f()
{
int i = 7;
return &i;
}
the "s" var should be destroyed after the function returns, right? But what happens to the memory pointed to by the pointer returned by c_str()? Do I have to free/delete the memory pointed to by the pointer returned by c_str()?Code:const char *f()
{
string s("whatever");
return s.c_str();
}
10x