They say that a local variable will be allocated and automatically freed when the function ends in C / C ++.
According to my understanding, when it was released, the value held by the local variable will also be destroyed !!! Please correct me if I am wrong
Consider the following code:
void doSomething(int** num)
{
int a = 10;
*num = &a;
}
void main()
{
int* number;
doSomething(&number);
cout << *number << endl;
}
Can anyone clarify for me?
source
share