But from the article I have read: 3 is wrong too. I am really confused.
) Fairly Easy. What is wrong with the following function? Explain.
char* GetName()
{
return "Bill Clinton";
}
Answer: The string "Bill Clinton" is allocated on the stack and thus deallocated when the function returns. The function returns a pointer that cannot be trusted, aka a bad pointer.
) Fairly Easy. What is wrong with the following function? Explain.
char* GetName()
{
return "Bill Clinton";
}
Answer: The string "Bill Clinton" is allocated on the stack and thus deallocated when the function returns. The function returns a pointer that cannot be trusted, aka a bad pointer.