各位高手,我这条代码报错提示如下,是什么问题啊?求指点,分不多,见谅!先谢过!
#include<stdio.h>#include<string.h>
#include<malloc.h>
#define FORMAT "%d,%s,%c,%d,%d,%d,%f,%f,%f,%f,%f"
#define LEN sizeof(Student)
struct date
{
int year;
int month;
int day;
};
typedef struct
{
int Num;
char Name[10];
char Sex;
struct date birthday[100];
float English,DataStructure,CPlusPlus;
float Sum,Average;
struct date*next;
}Student;
Student stud[100];
struct date birthday[100];
int count=0;
Student*creat(void) /*创建链表*/
{
Student*head,*p1,*p2;
p1=p2=(Student*)malloc(LEN); /*开辟一个新单元*/
scanf(FORMAT,&p1->Num,p1->Name,&p1->Sex,&p1->birthday->year,&p1->birthday->month,&p1->birthday->day,&p1->English,&p1->DataStructure,&p1->CPlusPlus,&p1->Sum,&p1->Average);
head=NULL;
while(p1->Num!=0)
{
count=count+1;
if(count==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(Student*)malloc(LEN);
scanf(FORMAT,&p1->Num,p1->Name,&p1->Sex,&p1->birthday->year,&p1->birthday->month,&p1->birthday->day,&p1->English,&p1->DataStructure,&p1->CPlusPlus,&p1->Sum,&p1->Average);
}
p2->next=NULL;
return(head);
}
Student*Add(Student*head,Student*stu) /*插入节点*/
{
Student*p0,*p1,*p2;
p1=head;
p0=stu;
if(head==NULL)
{
head=p0;
p0->next=NULL;
}
else
{
while((p0->Num>p1->Num)&&(p1->next!=NULL))
{
p2=p1;
p1=p1->next;
}
if(p0->Num<=p1->Num)
{
if(head==p1)
head=p0;
else
p2->next=p0;
p0->next=p1;
}
else
{
p1->next=p0;p0->next=NULL;
}
}
count=count+1;
return(head);
}
void main()
{
Student stud1;
printf("请输入要添加的学生信息:");
scanf(FORMAT,&stud1.Num,stud1.Name,&stud1.Sex,&stud1.birthday->year,&stud1.birthday->month,&stud1.birthday->day,&stud1.English,&stud1.DataStructure,&stud1.CPlusPlus,&stud1.Sum,&stud1.Average);
Add(stud,stud1);
}
D:\MSDev98\MyProjects\x3\x3.c(72) : warning C4133: '=' : incompatible types - from 'struct Student *' to 'struct date *'
D:\MSDev98\MyProjects\x3\x3.c(83) : error C2115: 'function' : incompatible types
D:\MSDev98\MyProjects\x3\x3.c(83) : warning C4024: 'Add' : different types for formal and actual parameter 2