linux-sysprog · beginner · ~15 min
Avoid returning a pointer to the thread's dead stack.
Implement int return_method_safe(const char *how) returning 1 for "heap-pointer" or "value-via-intptr" and 0 for "address-of-local" (which dangles after the thread exits).
#include <string.h>
int return_method_safe(const char *how) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.