returning pointer to a local variable [duplicate]
问题 This question already has answers here : How to access a local variable from a different function using pointers? (10 answers) Closed 4 years ago . What happens when a pointer to a local variable is returned by a function? for example int* foo() { int local; int* ptr = &local; return ptr; } will compiler issue a warning or will it compile and produce unexpected results?? 回答1: Similar kind of question has already been asked : Stack Overflow, local pointer There are somethings in C which are