双指针(指向指针)在C语言中

双指针(指向指针)在c语言中

指针用于存储变量的地址。因此,当我们定义一个指针到指针时,第一个指针用于存储第二个指针的地址。因此它被称为双指针

算法

Begin   Declare v of the integer datatype.      Initialize v = 76.   Declare a pointer p1 of the integer datatype.   Declare another double pointer p2 of the integer datatype.   Initialize p1 as the pointer to variable v.   Initialize p2 as the pointer to variable p1.   Print “Value of v”.      Print the value of variable v.   Print “Value of v using single pointer”.      Print the value of pointer p1.   Print “Value of v using double pointer”.      Print the value of double pointer p2.End.

登录后复制

一个理解双指针的简单程序:

示例

int main() {   int v = 76;   int *p1;   int **p2;   p1 = &v;   p2 = &p1;   printf("Value of v = %d", v);   printf("Value of v using single pointer = %d", *p1 );   printf("Value of v using double pointer = %d", **p2);   return 0;}

登录后复制

输出

Value of v = 76Value of v using single pointer = 76Value of v using double pointer = 76

登录后复制

以上就是双指针(指向指针)在C语言中的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2582542.html

(0)
上一篇 2025年3月6日 14:20:04
下一篇 2025年3月1日 05:53:37

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论