一、概念
/*
char c = 'a';
char *cp;
cp = &c;
char **cpp;
cpp = &cp;
*cp == c
*cpp == cp;
**cpp == *(*cp) == *cp == c
*/
二、代码
#include <stdio.h>
int main()
{
/*
char charValue = 'l';
char *p;
p = &charValue;
// charValue = 'n';
*p = 'n';
printf("%c\n",*p);
*/
/*
char charValue = 'l';
// 1.拷贝需要指向的变量的 数据类型 和名称
// 2.在数据类型 和变量名称 之间加上一颗星
// 3.修改变量名称
char *charValueP;
charValueP = &charValue;
// 1.拷贝需要指向的变量的 数据类型 和名称
// 2.在数据类型 和变量名称 之间加上一颗星
// 3.修改变量名称
char **charValuePP; // 不管有几颗* 只要是指针 就占用8个字节
printf("size = %lu\n",sizeof(charValuePP));
charValuePP = &charValueP;
// charValue = 'j';
// *charValueP == charValue
// *charValueP = 'j';
// *charValuePP == charValuePP
// printf("%c\n",*charValueP);
// &charValue == charValueP
printf("&charValue = %p\n",&charValue);
printf("charValueP = %p\n",charValueP);
// &charValueP == charValuePP
printf("&charValueP = %p\n",&charValueP);
printf("charValuePP = %p\n",charValuePP);
// *charValuePP == charValueP
// *pp = p
// **charValuePP = *(*charValueP) = *charValueP = l
**charValuePP = 'n';
printf("%c\n",charValue);
printf("%c\n",**charValuePP);
*/
char c = 'a';
char *cp;
cp = &c;
char **cpp;
cpp = &cp;
char ***cppp;
cppp = &cpp;
printf("cppp = %c\n",***cppp);
/*
*cp == c
*cpp == cp;
**cpp == *(*cp) == *cp == c
多级指针的操作,最简单的方式,就是通过几颗星来存储,就通过几个星来访问
还有一种方式 就是画图,看图片中有几个箭头,就用几颗星来访问
*/
printf("c = %c\n",c);
printf("*cp = %c\n",*cp);
printf("&c = %p\n",&c);
printf("cp = %p\n",cp);
printf("*cpp = %p\n",*cpp);
printf("**cpp = %c\n",**cpp);
return 0;
}