我是一个 C 初学者,按照例题写了一遍程序 编译出现错误 望高手指教一下 这是一个获得变量地址编号的例题

#include "stdio.h"
int main()
{
int input;
int *p;
input=12;
P=&input;
printf("%d\n",input);
printf("%P\n",p);
return 0;
}
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
F:\Program Files\Microsoft Visual Studio\MyProjects\lx\1.cpp(7) : error C2065: 'P' : undeclared identifier
F:\Program Files\Microsoft Visual Studio\MyProjects\lx\1.cpp(7) : error C2440: '=' : cannot convert from 'int *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.

1.obj - 1 error(s), 0 warning(s)

#include "stdio.h"
int main()
{
int input;
int *p;
input=12;
P=&input; //把P改成小写的p
printf("%d\n",input);
printf("%P\n",p); //这里第一个的P改成d, 第二个p前面加个*
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-06-21
我的C语言也差。
但是 main应该是void 无返回值吧?
你返回个0干什么的?追问

我不太清楚 貌似void main 无返回值 int main 最后需要返回个0 我刚学 不太清楚 但是例题是这样的 等待高手解决

追答

cannot convert from 'int *' to 'int'

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网