大家帮忙看看什么问题
#include<stdio.h>#include<string.h>
#include<stdlib.h>
#define NULL 0
struct node
{
char number[15];
char name[10];
char sex;
struct node *link;
}
struct node * creattab(int n)
{
int i;
struct node *phead,*ptail,*pnew;
pnew=(struct node *)malloc(sizeof(struct node));
if(pnew==NULL)
{
printf("内存不足!\n");
exit(1);
}
else
{
printf("Input number:");
gets(pnew->number);
printf("Input name:");
gets(pnew->name);
printf("Input sex:");
gets(pnew->sex);
pnew->link=NULL;
phead=pnew;
ptail=pnew;
}
for(i=1;i<n;i++)
{
pnew=(struct node *)malloc(sizeof(struct node));
if(pnew==NULL)
{
printf("内存不足!\n");
exit(1);
}
else
{
printf("Input number:");
gets(pnew->number);
printf("Input name:");
gets(pnew->name);
printf("Input sex:");
gets(pnew->sex);
pnew->link=NULL;
phead->link=pnew;
ptail->link=pnew;
ptail=pnew;
}
}
return(phead);
}
int main()
{
struct node *creattab(int n);
int m=3;
struct node *phead,*pnew,*p;
p=creattab(m);
phead=p;
return 0;
}
这是一个做链表的程序,我调了很多次都说struct node unexpected.我实在找不到有什么错误,
请个位多多指教,谢谢了!