int *something() {
int x = 5;
int *b = &x;
return b;
}
int main() {
int z = *something()
printf("%d",z);
}
how does this work if the function called something
is allocated on stack then the int x and int *b are removed after the it returns a value
if they were removed we wouldn't be able to deference the pointer returned by something
because what it pointed to was int x
which was deleted from stack