int a;
printf("address is %u", &a);
Which address is this..? I mean is this a compiler generated address i.e. virtual address or the loader given physical address in the RAM..?
As it prints different address every time, I guess it must be address in the RAM. Just want to make sure.
Please provide any links which give reference to your answer.
The address returned for a local variable in the user space is always a virtual address not the physical address.
The variable a
in your case is allocated on the local storage(stack) and every time you execute your program a stack space allocated to your function, the variable is located at particular offset within this stack frame, since the address of the stack being allocated to your program can be different everytime the address returned for the variable will be different as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With