C++中为什么输出的值总是不对

#include<stdio.h>
int main()
{
int a;
printf("please input the whole number of people:\n");
scanf("%d",&a);
printf("hello %d\n",&a);
return 0;
}
为什么不管输入什么值出现的结果都是1245025?
我这个程序哪里错了?新手求教!

第1个回答  2014-03-25
printf("hello %d\n",a);把地址符&去掉就行了,因为你那样输出的事变量的地址,它的地址在定义时已经确定了,跟你输入变量的值没有关系,
第2个回答  2014-03-25
printf("hello %d\n",&a); 如此输出的是a的地址,去掉&就好了
第3个回答  2014-03-25

应该是

printf("hello %d\n",a);

第4个回答  2014-03-25
printf("hello %d\n",a); // 去掉&

本回答被提问者采纳
第5个回答  2014-03-25
printf("hello %d\n",&a);改成printf("hello %d\n",a);
相似回答