Nearby lessons
54 of 72C - Dereferencing a Pointer
Learn how to use the * operator to read or change the value stored at the address held by a pointer.
Reading a Value Using a Pointer
When a pointer stores the address of a variable, *ptr gives the value at that address. This is called dereferencing.
Example01
Changing a Value Using a Pointer
You can assign a new value to *ptr. This changes the original variable because the pointer refers to its address.
Example02
Remember the Difference
&numbermeans the address ofnumber.ptrstores that address.*ptrmeans the value at that address.
📝 Key Takeaways
- The & operator gets an address.
- The * operator accesses the value at a pointer address.
- Changing *ptr can change the original variable.
🧠 Test Your Knowledge
2 QuestionsProgress: 0 / 2