Multiple Pointers Pointing to One Memory Address

2

C lets you create a situation where several pointers reference the exact same spot in memory. You can declare multiple pointers and make them all target the same variable. This isn’t just a theoretical quirk. It happens constantly in real code.

Consider this snippet:

Here, p grabs the address of i. q does the same. Then r takes the value of p. Since p holds the address of i, r now also points to i. The assignment operator copies the address from the right side to the left side. It doesn’t copy the data. It copies the location.

After these lines run, i has effectively gained aliases. You can now access the integer i through its original name or through any of the pointers.

The variable i now has four names: i, *p, *q, and *r.

There is no hard limit on how many pointers can hold that same address. You can chain them as deep as you need. Change *p, and *r sees the change. They are all looking at the same memory cell.

Any number of pointers can point to the same address.

This behavior is fundamental to how pointers work. It’s not a special case. It’s the default. Understanding this helps you avoid confusion when debugging. If you see unexpected values, check if multiple pointers are modifying the same location. It’s not magic. It’s just memory.