Lesson 18 of 23
Pointers: Working with Addresses
12 min 35 XP
Every variable lives at an address in memory; &x gives that address. A pointer is a variable that stores an address: int *p = &x;. *p reads or writes the value at that address (dereferencing).
Example: edit me and press Run
Output Loading C (first time takes a few seconds)
Press Run to see the result here.Dereferencing a NULL pointer crashes the program (a segmentation fault). Check for NULL before using a pointer.