Nearby lessons

54 of 72

C - 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
Loading editor…

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
Loading editor…

Remember the Difference

  • &number means the address of number.
  • ptr stores that address.
  • *ptr means 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 Questions
Progress: 0 / 2

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.