指向指针的指针

指向指针的指针

例如:

#include<stdio.h>
int main ()
{
	int num = 520;
	int *p = &num;
	int **pp = &p;
	
	...
	
	return 0;
} 

在这里p存放的num的地址,*p = num = 520,**pp存放的是p的地址所以用双层解引用(pp就是指向指针的指针)。

指针数组

#include<stdio.h>
int main ()
{
	char *cBooks[] = {
	"{C程序设计语言}",
	"{C专家编程}",
	"{C和指针}",
	"{C陷阱与缺陷}",
	"{C Primer Plus}",
	"{带你学C带你飞}"}; 
	//指针访问 
	
	char **ZW;
	char **myLOVE[4];
	int i;
	
	ZW = & cBooks[5];//指向字符指针的指针 
	myLOVE[0] = & cBooks[0]; 
	myLOVE[1] = & cBooks[1];
	myLOVE[2] = & cBooks[2];
	myLOVE[3] = & cBooks[3];
	
	printf("我要看的书有:
"); 
	
for ( i = 0; i < 4; i++);
	{
		printf("%s
",myLOVE[i]); 
	}
	
	return 0;
} 

*优势:
1.避免重复分配内存;
2.只需要进行一处修改;

原文地址:https://www.cnblogs.com/zw431387/p/10384992.html