C lets you create chaos or clarity with memory. You can have dozens of pointers all aiming at the exact same spot in RAM. This isn’t a bug. It’s a feature.
Consider a scenario where you declare an integer i. You then create three integer pointers: p, q, and r.
The code does exactly what you might expect. p grabs the address of i. q does the same. r copies whatever p is holding. Since p holds the address of i, r also points to i.
After these assignments run, you have one variable with four names. i is the original. *p accesses it. *q accesses it. *r accesses it.
How Pointer Assignment Works
The key here is understanding what happens during assignment. When you write q = &i, you aren’t copying the value of i. You are copying the location of i.
When you write r = p, you copy the address from p into r. No new memory is allocated. No data is duplicated. The address value moves from one pointer variable to another.
This means there is no hard limit on how many pointers can hold the same address. You can create a thousand pointers all pointing to i. They all refer to the same memory location.
There is no limit on the number of pointers that can hold (and therefore point to) the same address.
This behavior is fundamental to how C manages memory. It allows for flexible data structures like linked lists and trees. It also allows for efficient function arguments. Pass a pointer instead of a copy. Modify the original data directly.
But it also introduces risk. Change i through p. Look at i through q. The change is visible everywhere. There is only one source of truth.
The variable i now has four names. i. *p. *q. *r.
This is how C works. You have direct access to memory addresses. You can alias data freely. You just have to be careful about what you change.




























