Y
Hacker News
new
|
ask
|
show
|
jobs
by
rrauenza
2823 days ago
...like returning a pointer to the stack:
char *dupstr(const char *src) { char new[1024]; strlcpy(new, src, 1024); return new; }
1 comments
x0re4x
2823 days ago
stack_ret.c:5:10: warning: function returns address of local variable [-Wreturn-local-addr] return new;
link
Narishma
2823 days ago
Why is this a warning and not an error? Are there situations in which you would want to return the address of a local variable?
link