Chapter 5. Pointers, Arrays, and Structures
The sublime and the ridiculous are often so nearly related that it is difficult to class them separately. | ||
--Tom Paine |
Pointers — zero — arrays — string literals — pointers into arrays — constants — pointers and constants — references — void
*
— data structures — advice — exercises.
Pointers
For a type T, T*
is the type “pointer to T.” That is, a variable of type T*
can hold the address of an object of type T. For example:
char c = 'a'; char* p = &c; // p holds the address of c
or graphically:
Unfortunately, pointers to arrays and pointers to functions need a more complicated notation:
int* pi; // pointer to ...
Get The C++ Programming Language, Special Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.