请大神看下error C2664: 'strcpy' : cannot convert parameter 1 from 'int' to 'char *'
structcla*creatbook(){structcla*head,*tail,*p;intnum,n;charcname[50],xingzhi[20],time...
struct cla *creatbook()
{
struct cla *head,*tail,*p;
int num,n;
char cname[50],xingzhi[20],time[10],score[10];
int size=sizeof(struct cla);
head=tail=NULL;
printf("请输入学科编号:");
scanf("%d",&num);
getchar();
printf("请输入学科名:");
scanf("%s",cname);
getchar();
printf("请输入学科性质:");
scanf("%s",xingzhi);
getchar();
printf("请输入总学时:");
scanf("%d",&time);
getchar();
printf("请输入学分:");
scanf("%d",&score);
getchar();
while(1){
p=(struct cla *)malloc(size);
p->num=num;
strcpy(p->cname,cname);
strcpy(p->xingzhi,xingzhi);
strcpy(p->time,time);
strcpy(p->score,score);
p->time=time;
p->next=NULL;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
do{
printf("请输入学科编号:");
scanf("%d",&num);
n=yanzheng(head,num);
if(n==0)
break;
else
printf("您输入的编号已存在,请重新输入!\n");
}while(1);
if(num==0)
break;
else
{
printf("请输入学科编号:");
scanf("%d",&num);
printf("请输入学科名:");
scanf("%s",cname);
getchar();
printf("请输入学科性质:");
scanf("%s",xingzhi);
getchar();
printf("请输入总学时:");
scanf("%d",&time);
getchar();
printf("请输入学分:");
scanf("%d",&score);
getchar();
}
}
return head;
} 展开
{
struct cla *head,*tail,*p;
int num,n;
char cname[50],xingzhi[20],time[10],score[10];
int size=sizeof(struct cla);
head=tail=NULL;
printf("请输入学科编号:");
scanf("%d",&num);
getchar();
printf("请输入学科名:");
scanf("%s",cname);
getchar();
printf("请输入学科性质:");
scanf("%s",xingzhi);
getchar();
printf("请输入总学时:");
scanf("%d",&time);
getchar();
printf("请输入学分:");
scanf("%d",&score);
getchar();
while(1){
p=(struct cla *)malloc(size);
p->num=num;
strcpy(p->cname,cname);
strcpy(p->xingzhi,xingzhi);
strcpy(p->time,time);
strcpy(p->score,score);
p->time=time;
p->next=NULL;
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
do{
printf("请输入学科编号:");
scanf("%d",&num);
n=yanzheng(head,num);
if(n==0)
break;
else
printf("您输入的编号已存在,请重新输入!\n");
}while(1);
if(num==0)
break;
else
{
printf("请输入学科编号:");
scanf("%d",&num);
printf("请输入学科名:");
scanf("%s",cname);
getchar();
printf("请输入学科性质:");
scanf("%s",xingzhi);
getchar();
printf("请输入总学时:");
scanf("%d",&time);
getchar();
printf("请输入学分:");
scanf("%d",&score);
getchar();
}
}
return head;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询