error: invalid type argument of '->' (have 'Course')
风-之-谷 2014-03-01 07:17:29 typedef struct SC{
int Cno;
int Grade;
struct SC *next;
}SC;
typedef struct Student{
char Sno[8];
char Sname[20];
char Ssex[2];
int Sage;
char Sdept[2];
struct Student *next;
struct SC *scnext;
}Student,*LinkList;
typedef struct{ //课程的结构体
int Cno; //课程编号
char Cname[10]; //课程名
double Ccredit; //课程的学分
}Course;
typedef struct SqList //课程的存储数据结构
{
Course *elem; // 存储空间基址
int length; // 当前长度
int listsize; // 当前分配的存储容量(以sizeof(ElemType)为单位)
}SqList;
Status Search_TotallCredit(LinkList L,SqList sql){ //根据学号查询学生的总学分
char sno[8]; //所查询的学号
SC *sc;
double totall=0; //总学分
Student *s=L->next;
printf("请输入你所要查询学生的学号:\n");
scanf("%s",sno);
while( strcmp(s->Sno,sno) ){
s=s->next;
if(s==NULL){
printf("您所输入的学号有误,不存在此学号的学生。\n");
return ERROR;
}
}
sc=s->scnext;
while(sc!=NULL){
totall+=sql.elem[sc->Cno]->Ccredit; // error: invalid type argument of '->' (have 'Course')
sc=sc->next;
}
printf("%s同学的总学分为%lf\n",s->Sname,totall);
return OK;
}
为什么总是报错 error: invalid type argument of '->' (have 'Course')