Pointer Basics
- Variables are stored in memory locations with addresses. A pointer variable stores the address of another variable.
- Pointer variables are declared with a type followed by an asterisk (e.g. int *ptr). They can be initialized by using the address of operator (&) on a variable of the correct type.
- The indirection operator (*) is used to access the value stored at the address a pointer points to. Pointer arithmetic and pointer comparisons are also allowed. Arrays and strings can be accessed and manipulated using pointers. Null pointers indicate a pointer does not point to a valid memory location.