好记性当不得烂笔头 说的太对了 很多问题以前整过 后来没用基本都忘记了 最近发现指针太生疏了 重新瞎看了下
1.指针访问是间接的,指针存储了一个地址,对于访问,先要取得自己的内容,然后利用*操作符取指向地址的内容。
2.指针数组与数组指针
<c程序设计语言>中的关于这个的解释:
Newcomers to C are sometimes confused about the difference between a two-dimensional array and an array of pointers, such as name in the example above. Given the definitions
int a[10][20];
int *b[10]; //按结合性 [ ] 优先级高于* 所以b是数组 数组存储的是int型的指针
then a[3][4] and b[3][4] are both syntactically legal references to a single int. But a is a true two-dimensional array: 200 int-sized locations have been set aside, and the conventional rectangular subscript calculation 20 * row +col is used to find the element a[row,col]. For b, however, the definition only allocates 10 pointers and does not initialize them; initialization must be done explicitly, either statically or with code. Assuming that each element of b does point to a twenty-element array, then there will be 200 ints set aside, plus ten cells for the pointers. The important advantage of the pointer array is that the rows of the array may be of different lengths. That is, each element of b need not point to a twenty-element vector; some may point to two elements, some to fifty, and some to none at all.
Although we have phrased this discussion in terms of integers, by far the most frequent use of arrays of pointers is to store character strings of diverse lengths, as in the function month_name. Compare the declaration and picture for an array of pointers:
char *name[] = { "Illegal month", "Jan", "Feb", "Mar" };

with those for a two-dimensional array:
char aname[][15] = { "Illegal month", "Jan", "Feb", "Mar" };

3.还有一个二级指针的问题
如 char **p
p是一个指针,指向的内容(注意是内容)是*p ,很不巧*p也是一个指针,他能指向到其他地方,他指向的内容三 **p
浙公网安备 33010602011771号