C Programming • C17 baseline, standards-specific features labeled
Pointers, Addresses, and Dereferencing
Use pointers to refer to objects while respecting type, lifetime, and nullability.
A pointer stores the address of an object or function. The unary & operator obtains an object address, and * accesses the pointed-to object. A pointer must refer to a live object before it is dereferenced; a null pointer is not a usable object address.
Example
#include <stdio.h>
int main(void) {
int score = 80;
int *score_address = &score;
*score_address += 5;
printf("%d\n", score);
return 0;
}
What to expect
85
Key idea: Before dereferencing, establish that a pointer is non-null and still refers to a live object.