C语言指针在生活中的,C语言指针的指针

在C语言中指针的指针概念中,指针指向另一个指针的地址。

在C语言中,指针可以指向另一个指针的地址。我们通过下面给出的图来理解它:

15e5d60e12b62ab06e4b15af0ce98888.png

我们来看看指向指针的指针的语法 –

int **p2;

指针的指针的示例

下面来看看一个例子,演示如何将一个指针指向另一个指针的地址。参考下图所示 –

f7ef6aa66f004086e926ac0382a87c8b.png

如上图所示,p2包含p的地址(fff2),p包含数字变量的地址(fff4)。

下面创建一个源代码:pointer-to-pointer.c,其代码如下所示 –

#include #include void main() { int number = 50; int *p;//pointer to int int **p2;//pointer to pointer p = &number;//stores the address of number variable p2 = &p; printf("Address of number variable is %x n", &number); printf("Address of p variable is %x n", p); printf("Value of *p variable is %d n", *p); printf("Address of p2 variable is %x n", p2); printf("Value of **p2 variable is %d n", **p2); }

执行上面示例代码,得到以下结果 –

Address of number variable is 3ff990 Address of p variable is 3ff990 Value of *p variable is 50 Address of p2 variable is 3ff984 Value of **p2 variable is 50

¥ 我要打赏   纠错/补充 收藏

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值