您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

解释一下C语言中的引用和指针?

2025/4/9 1:56:16发布37次查看
问题使用示例解释c编程语言中引用和指针的概念。
引用它是我们声明的变量的替代名称。
可以通过传值方式访问。
它不能保存空值。
语法datatype *variablename
例如,int *a; //a包含int类型变量的地址。
指针它存储变量的地址。
我们可以使用指针来保存空值。
可以通过引用传递来访问它。
在声明变量时不需要初始化。
语法pointer variable= & another variable;
example 实例演示
#include<stdio.h>int main(){ int a=2,b=4; int *p; printf("add of a=%d
",&a); printf("add of b=%d
",&b); p=&a; // p points to variable a printf("a value is =%d
",a); // prints a value printf("*p value is =%d
",*p); //prints a value printf("p value is =%d
",p); //prints the address of a p=&b; //p points to variable b printf("b value is =%d
",b); // prints b value printf("*p value is =%d
",*p); //prints b value printf("p value is =%d
",p); //prints add of b}
输出add of a=-748899512add of b=-748899508a value is =2*p value is =2p value is =-748899512b value is =4*p value is =4p value is =-748899508
以上就是解释一下c语言中的引用和指针?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product