0Pricing
C++ Academy · Lesson

Dereferencing and Pointer Arithmetic

Read memory through pointers and walk arrays with pointer arithmetic.

Reading Through a Pointer

The unary * operator reads the value the pointer points to.

int x = 42;
int* p = &x;
std::cout << *p;   // 42

Writing Through a Pointer

You can also use *p on the left side of an assignment to write to the target.

*p = 100;
std::cout << x;   // 100

All lessons in this course

  1. Raw Pointers and the Address-of Operator
  2. Dereferencing and Pointer Arithmetic
  3. nullptr and Null Pointer Safety
  4. When to Use Pointers vs References
← Back to C++ Academy