[求助]简单的连表题
着里面有好多错误
帮忙看看 怎么改
#include"stdio.h"
#include"stdlib.h"
struct slist
{
int data;
struct slist *next;
};
typedef struct slist SLIST;
SLIST *creat() ;
void print(SLIST *head) ;
main()
{
SLIST *head;
head=creat();
print(head);
}
SLIST *creat()
{
int c;
SLIST *h,*s,*r;
h=(SLIST*)malloc(sizeof(SLIST));
r=h;
scanf("%d",&c);
while(c!=-1)
{
s=(SLIST*)malloc(sizeof(SLIST));
s.data=c;
r.next=s;
r=s;
scanf("%d",&c);
}
r.next='\0';
return h;
}
void print(SLIST *head)
{
SLIST *p;
p=head.next;
if(p=='\0')
printf("连表为空\n");
else{
printf("head");
double{
printf("->%d",p.data);
p=p.next;
}
while(p!='\0');
printf("->end\n");
}
}