简单链表
说是unable to open include file 'malloc.h'各位帮看看哪错了,谢谢了
#include <malloc.h>
#include <stdio.h>
#define Len sizeof(struct student)
struct student
{long num;
char sex;
struct student *next;
};
int n;
struct student *creat(void)
{struct student *head,*p1,*p2;
n=0;
p1=p2=(struct student *)malloc(Len);
scanf("%ld%c",&p1->num,&p1->sex);
head=NULL;
while(p1->num!=0)
{n++;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(Len);
scanf("%ld%c",&p1->num,&p1->sex);
}
p2->next=NULL;
return (head);
}
main()
{struct student *p;
p=creat();
printf("\n");
if(p!=NULL)
{printf("%ld,%c\n",p->num,p->sex);
p=p->next;
}
}
[ 本帖最后由 xdyuan33 于 2009-9-19 12:50 编辑 ]