请问我这段程序那里出错了!(c语言)

来源:百度知道 编辑:UC知道 时间:2024/07/08 18:16:42
我前插发建立单链表失败!是c语言的,请问哪个高手能帮我!
#include "stdio.h"
#define NULL 0
typedef struct node{DataType data;
struct node *link;}LNode;
LNode *createfirst()
{LNode *s,*h;
int x,tag;
printf("Input the end label:");
scanf("%d",&tag);
h=NULL;
printf("Input data:");
scanf("%d",&x);
while(x!=tag)
{s=(LNode*)malloc(sizeof(LNode));
s->data=x;
s->link=h;
h=s;
scanf("%d",&x);
}
return h;
}

DataType 类型是int....
修改如下
#include "stdio.h"
#include <malloc.h>
#define NULL 0
typedef struct node{
int data;
struct node *link;
}LNode;

LNode *createfirst()
{LNode *s,*h;
int x,tag;
printf("Input the end label:");
scanf("%d",&tag);
h=NULL;
printf("Input data:");
scanf("%d",&x);
while(x!=tag)
{s=(LNode*)malloc(sizeof(LNode));
s->data=x;
s->link=h;
h=s;
scanf("%d",&x);
}
return h;
}

int main()
{
LNode *p=createfirst();
return 0;
}

这个怎么改啊,连个main()都没有啊