Hello;
I have a question concerning a small problem I am facing.
If the variables within a function are temporary. for example:
int* simpleCopy(int *newvalue)
{
int result;
int* pointerToResult;
result = *newvalue;
pointerToResult = &result;
return pointerToResult;
}
If we try to use this function it will work. But I don't understand why.
from the compiler's perspective:
the function will create a variable named result and a pointer that point to this variable. and then will return the pointer. But when the function finishes and return the pointer the variable should be already gone yet It works and gives me accurate result. Could anyone explain the reason to me please.
Thanks in previos