注册 登录
编程论坛 C++教室

c++

lljojo501 发布于 2012-09-26 22:57, 366 次点击
我是入门级
在vc中运行一下提示错误:no operator defined which takes a right-hand operand of type 'int *' (or there is no acceptable conversion)

#include<iostream.h>
main()
{
    int i,a[20];
    int *p;
    p=a;
    for(i=0;i<10;i++)
    cin>>p;}

请高手指教
4 回复
#2
caoyanchuang2012-09-26 23:05
p是一个指针,不可以由通过终端对它赋值的。
#3
小糊涂神c302012-09-27 09:11
最后一句改为cin>>*p;
#4
梦幻尘2012-09-27 12:13
同上,但有点要提醒,main函数也要写返回值类型,可以改为void main(),虽然也没错,但你以后会明白的;
且iostream最好不要带后缀.h,那是C 语言习惯。
#5
有容就大2012-09-28 18:51
应该输入指针指向的内容。
1