做了一个函数:
#include
#include
#include
//
#define NULL 0
#define LEN sizeof(struct goods)
//
struct goods//建立结构体
{char name[10];
int number;
float price;
int date;
struct goods *next;
};
int n;//全局变量N
//
struct goods *creat(void)//构造函数
{struct goods *head;
struct goods *p1,*p2;
n=0;
p1=p2=(struct goods *)malloc(LEN);
cin>>&p1->name>>&p1->number>>&p1->price>>&p1->date;
head=NULL;
while(p1->name!=0)
{n++;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct goods *)malloc(LEN);
cin>>&p1->name>>&p1->number>>&p1->price>>&p1->date;
}
p2->next=NULL;
return(head);
}
试运行时总是出现报错,都是错在两个cin上.提示是
F:\c++程序\仓库管理.cpp(32) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'char (*)[10]' (or there is no acceptable conversion)
请教达人这是怎么回事啊