KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Say you have the following function: char *getp() { char s[] = "hello"; return s; } Since the function is returning a pointer to a local variable in the function to be used outside, will it cause a memory leak? P.S. I am still learning C so my question may be a bit naive... [Update] So, if say you want to return a new char[] array (ie maybe for a substring function), what do you return exactly? Should it be pointer to an external variable ? ie a char[] that is not local to the function?
Tags (comma-separated)
Save Edits
Cancel