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; // 42Writing 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; // 100All lessons in this course
- Raw Pointers and the Address-of Operator
- Dereferencing and Pointer Arithmetic
- nullptr and Null Pointer Safety
- When to Use Pointers vs References