|
|
Q: What are pointers really good for, anyway?
A: They're good for lots of things, such as:
- dynamically-allocated arrays (see questions 6.14 and 6.16)
- generic access to several similar variables
- (simulated) by-reference function parameters (see question 4.8 and 20.1)
- malloc'ed data structures of all kinds, especially trees and linked lists
- walking over arrays (for example, while parsing strings)
- efficient, by-reference ``copies'' of arrays and structures, especially as function parameters
(Note that this is hardly a comprehensive list!)
See also question 6.8. |
|