KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm working with some code that widely uses the idiom of returning a pointer to a static local variable. eg: char* const GetString() { static char sTest[5]; strcpy(sTest, "Test"); return sTest; } Am I right in thinking that this is safe? PS, I know that this would be a better way of doing the same thing: char* const GetString() { return "Test"; } Edit: Apologies, the function signature should of course be: const char* GetString();
Tags (comma-separated)
Save Edits
Cancel