c语言指针可以指向其他程序吗,c语言指针示例_C程序演示双指针示例(指向指针的指针)...

c语言指针示例

In this program, we have to declare, assign and access a double pointer (pointer to pointer) in C.

在此程序中,我们必须在C中声明,分配和访问双指针(指向指针的指针)。

As we know that, pointers are the special type of variables that are used to store the address of another variable.

众所周知,指针是变量的特殊类型,用于存储另一个变量的地址。

But, when we need to store the address of a pointer variable, we cannot assign it in a pointer variable. To store address of a pointer variable, we use a double pointer which is also known as pointer to pointer.

但是 ,当我们需要存储指针变量的地址时,我们不能将其分配给指针变量。 为了存储指针变量的地址,我们使用了一个双指针,也称为指针指针 。

In this C program, we will understand how to declare, assign and access a double pointer (pointer to pointer)?

在此C程序中,我们将了解如何声明,分配和访问双指针(指向指针的指针)?

双指针(指向指针的指针)的C程序 (C program for double pointer (pointer to pointer)) s> s> s>

/*C program to demonstrate example of double pointer (pointer to pointer).*/

#include int main()

{

int a; //integer variable

int *p1; //pointer to an integer

int **p2; //pointer to an integer pointer

p1=&a; //assign address of a

p2=&p1; //assign address of p1

a=100; //assign 100 to a

//access the value of a using p1 and p2

printf("\nValue of a (using p1): %d",*p1);

printf("\nValue of a (using p2): %d",**p2);

//change the value of a using p1

*p1=200;

printf("\nValue of a: %d",*p1);

//change the value of a using p2

**p2=200;

printf("\nValue of a: %d",**p2);

return 0;

}

Output

输出量

Value of a (using p1): 100

Value of a (using p2): 100

Value of a: 200

Value of a: 200

翻译自: https://www.includehelp.com/c-programs/c-pointer-program-to-demonstrate-example-of-pointer-to-pointer-double-pointer.aspx

c语言指针示例

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值