Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22009

In C language, can I access local variable of main function in another function through stack pointer?

$
0
0

I need to access the value of variable a which is defined in main function without passing it as argument.

main()
{
    int a=10;

    func();

    printf("%d\n",a);
}

void func(){
//i need access of variable a here.
}

How can i do this?


Viewing all articles
Browse latest Browse all 22009

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>