新手求教啊
#include<stdio.h>#include<stdlib.h>
struct node
{
int data;
struct node *next;
}
typedef struct node SLIST;
SLIST *creat_slist1()
{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;
}
main()
{
SLIST *head;
head=creat_slist1();
return 0;
}
搞不懂为什么会出现这个错误
error C2236: unexpected 'struct' 'node' struct node
{
int data;
struct node *next;
}
结构体声明最后要用分号结尾
页:
[1]