c语言中*ptr和&ptr有什么区别?
答案:1 悬赏:80 手机版
解决时间 2021-11-18 21:45
- 提问者网友:疯孩纸
- 2021-11-18 05:59
c语言中*ptr和&ptr有什么区别?
最佳答案
- 五星知识达人网友:行雁书
- 2021-11-18 06:56
若ptr是合法且有效的指针,那么*ptr是取ptr指向的目标的内容,&ptr是取当前平台下存放指针ptr的地址。如:
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
int x=7,*ptr;
ptr=&x;//使ptr指向x,即使ptr有效
printf("*ptr = %d\n&ptr = %p\n",*ptr,&ptr);
return 0;
}
//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
int x=7,*ptr;
ptr=&x;//使ptr指向x,即使ptr有效
printf("*ptr = %d\n&ptr = %p\n",*ptr,&ptr);
return 0;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯