When we associate '&' with a variable the address we get is the virtual address or the physical address?

c, operating-system

Solution

If you run the program on a system with virtual memory, you will get a virtual address. If you run on a system without virtual memory (typically smaller embedded systems), you will get a physical address.

Also note that the format `"%u"` is wrong for pointers, if you want to use `printf` to print a pointer you should use `"%p"`. See e.g. this reference.

Problem

``` #include<stdio.h> int main() { int a; printf(" %u ",&a); return 0; } ``` The address we get is the virtual address of the process or the physical address when the process is running in main memory. Please help I am confused !!

Original source

Related problems