您的位置:首页 > 其它

关于指针基础含意的程序示例及说明

2014-04-14 10:59 204 查看
# include <stdio.h>

void main(void)
{
int n = 5, * p;
p = &n;
printf("%d\n", &n);
printf("%d\n", p); //p = &n;
printf("%d\n", &(*p)); //p = &n,则*p = n,即&(*p) = &n;
printf("%d\n", *(&p)); //【个人理解:&p表示指针变量p的地址,则*(&p)=p】
/* 以上四个表达式输出的是同样的值 */

printf("%d\n", &p);// &p表示指针变量p的地址;
/* 该表达式输出的是p变量的地址值 */

printf("%d\n", n);
printf("%d\n", *p); // *p = n;
printf("%d\n", *(&n)); *(&n) = n;
/* 以上三个表达式输出的是同样的值:5 */
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: