1684
备注:
|
1258
|
删除的内容标记成这样。 | 加入的内容标记成这样。 |
行号 1: | 行号 1: |
[[Navigation(slideshow)]] | ## page was renamed from Pointers and Arrays [[Navigation(slides)]] |
行号 3: | 行号 4: |
= Chapter 5 - Pointers and Arrays = | = Chapter 5 - Pointers and Arrays 指针与数组 = |
行号 10: | 行号 11: |
1. ["/5.01 Pointers and Addresses"] 1. ["/5.02 Pointers and Function Arguments"] 1. ["/5.03 Pointers and Arrays"] 1. ["/5.04 Address Arithmetic"] 1. ["/5.05 Character Pointers and Functions"] 1. ["/5.06 Pointer Arrays; Pointers to Pointers"] 1. ["/5.07 Multi-dimensional Arrays"] 1. ["/5.08 Initialization of Pointer Arrays"] 1. ["/5.09 Pointers vs. Multi-dimensional Arrays"] 1. ["/5.10 Command-line Arguments"] 1. ["/5.11 Pointers to Functions"] 1. ["/5.12 Complicated Declarations"] [[Navigation(children)]] |
[[Include(^TCPL/5\.[0-9][0-9] .*, , titlesonly)]] |
Chapter 5 - Pointers and Arrays 指针与数组
A pointer is a variable that contains the address of a variable. Pointers are much used in C, partly because they are sometimes the only way to express a computation, and partly because they usually lead to more compact and efficient code than can be obtained in other ways. Pointers and arrays are closely related; this chapter also explores this relationship and shows how to exploit it.
Pointers have been lumped with the goto statement as a marvelous way to create impossible-to-understand programs. This is certainly true when they are used carelessly, and it is easy to create pointers that point somewhere unexpected. With discipline, however, pointers can also be used to achieve clarity and simplicity. This is the aspect that we will try to illustrate.
The main change in ANSI C is to make explicit the rules about how pointers can be manipulated, in effect mandating what good programmers already practice and good compilers already enforce. In addition, the type void * (pointer to void) replaces char * as the proper type for a generic pointer. Include(^TCPL/5\.[0-9][0-9] .*, , titlesonly)