error C2664: 'strcpy' : cannot convert parameter 1 from 'int' to 'char *'
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<malloc.h>typedefstructS...
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
typedef struct Student
{
char num[10];//学号
char name[15];//姓名
int cgrade;//c语言成绩
int mgrade;//数学成绩
int egrade;//英语成绩
int total;//总分
float ave;//平均分
int mingci;//名次
struct Student*next;
}student;
#define LENGTH sizeof(student)
char str[20];
student * fout()
{
FILE * fp;
student * p1,*p2,*p3,*head;
p1=(student *)malloc(LENGTH);
head=NULL;
fp=fopen("file","r");
do
{
fread(p1,LENGTH,1,fp);
p2=(student *)malloc(LENGTH);
strcpy(p2->num,p1->num);
strcpy(p2->name,p1->name);
strcpy(p2->cgrade,p1->cgrade);
strcpy(p2->mgrade,p1->mgrade);
strcpy(p2->negrade,p1->egrade);
strcpy(p2->total,p1->total);
strcpy(p2->ave,p1->ave);
strcpy(p2->mingci,p1->mingci);
p2->next=p1->next;
if(head==NULL)
head=p2;
else
p3->next=p2;
if(p2->next==NULL)
break;
p3=p2;
}while(1);
fclose(fp);
return head;
}
strcpy(p2->cgrade,p1->cgrade);这几个有问题
strcpy(p2->mgrade,p1->mgrade);
strcpy(p2->negrade,p1->egrade);
strcpy(p2->total,p1->total);
strcpy(p2->ave,p1->ave);
strcpy(p2->mingci,p1->mingci); 展开
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
typedef struct Student
{
char num[10];//学号
char name[15];//姓名
int cgrade;//c语言成绩
int mgrade;//数学成绩
int egrade;//英语成绩
int total;//总分
float ave;//平均分
int mingci;//名次
struct Student*next;
}student;
#define LENGTH sizeof(student)
char str[20];
student * fout()
{
FILE * fp;
student * p1,*p2,*p3,*head;
p1=(student *)malloc(LENGTH);
head=NULL;
fp=fopen("file","r");
do
{
fread(p1,LENGTH,1,fp);
p2=(student *)malloc(LENGTH);
strcpy(p2->num,p1->num);
strcpy(p2->name,p1->name);
strcpy(p2->cgrade,p1->cgrade);
strcpy(p2->mgrade,p1->mgrade);
strcpy(p2->negrade,p1->egrade);
strcpy(p2->total,p1->total);
strcpy(p2->ave,p1->ave);
strcpy(p2->mingci,p1->mingci);
p2->next=p1->next;
if(head==NULL)
head=p2;
else
p3->next=p2;
if(p2->next==NULL)
break;
p3=p2;
}while(1);
fclose(fp);
return head;
}
strcpy(p2->cgrade,p1->cgrade);这几个有问题
strcpy(p2->mgrade,p1->mgrade);
strcpy(p2->negrade,p1->egrade);
strcpy(p2->total,p1->total);
strcpy(p2->ave,p1->ave);
strcpy(p2->mingci,p1->mingci); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询