Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can address of pointers in two programs be equal? [closed]

Tags:

c

pointers

When two programs are running at the same time, and you print the address to which the pointer points to, can it happen that both programs print the same value?

like image 931
Saurabh Rana Avatar asked Sep 10 '25 03:09

Saurabh Rana


1 Answers

Yes. The program runs in a virtual memory allocated by the OS. The amount of virtual memory is determined by the processor architecture.

The address you see refers to the virtual memory address and not to the physical RAM address.

I would add that each process running on a system gets a huge address space (2^32 on a 32-bit OS and 2^64 on a 64-bit OS) allocated to it. It's on this virtual address space that a process runs.

like image 51
rjv Avatar answered Sep 12 '25 20:09

rjv