- What will be output of following code?
int * f(){
int a = 10;
int *b = &a;
return b;
}
main(){
int *temp = f();
cout<<*temp<<endl;
return 0;
}
Answer: Either 0 or garbage value, as it will be a dangling pointer.
int * f(){
int a = 10;
int *b = &a;
return b;
}
main(){
int *temp = f();
cout<<*temp<<endl;
return 0;
}
Answer: Either 0 or garbage value, as it will be a dangling pointer.