Hi guys, how local variable ‘a’ goes outside of function? Is it possible? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi guys, how local variable ‘a’ goes outside of function? Is it possible?

#include <iostream> using namespace std; void func(int** nVal) { int a = 10; *nVal=&a; cout<<nVal<<endl; } int main() { int s=20; int* b=&s; cout<<*b<<endl; func(&b); cout<<*b<<endl; cout<<*b; return 0; }

7th Sep 2019, 6:34 PM
Navaneethan B
Navaneethan B - avatar
0 Answers