#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
ElemType data;
struct Node *next;
}Node,*LinkList;
void InitList(LinkList *L)
{
*L=(LinkList)malloc(sizeof(Node));
(*L)->next=NULL;
}
void GreaterFromHead(LinkList L)
{
Node *s;
char c;
int flag=1;
while(flag)
{
c=getchar();
if(c!='$')
{
s=(Node *)malloc(sizeof(Node))
s->data=c;
s->next=L->next;
L->next=s;
}
else flag=0;
}
}
int main()
{
LinkList L;
InitList (&L);
GreaterFromHead (L);
return 0;
}
报错:
--------------------Configuration: Test - Win32 Debug--------------------
Compiling...
1.c
G:\1\Test\1.c(5) : error C2061: syntax error : identifier 'ElemType'
G:\1\Test\1.c(8) : error C2059: syntax error : '}'
G:\1\Test\1.c(9) : error C2143: syntax error : missing ')' before '*'
G:\1\Test\1.c(9) : error C2143: syntax error : missing '{' before '*'
G:\1\Test\1.c(9) : error C2059: syntax error : ')'
G:\1\Test\1.c(10) : error C2054: expected '(' to follow 'L'
G:\1\Test\1.c(14) : error C2143: syntax error : missing ')' before '*'
G:\1\Test\1.c(14) : error C2143: syntax error : missing '{' before '*'
G:\1\Test\1.c(14) : error C2059: syntax error : ')'
G:\1\Test\1.c(15) : error C2054: expected '(' to follow 'L'
G:\1\Test\1.c(38) : error C2065: 'LinkList' : undeclared identifier
G:\1\Test\1.c(38) : error C2146: syntax error : missing ';' before identifier 'L'
G:\1\Test\1.c(39) : warning C4013: 'InitList' undefined; assuming extern returning int
G:\1\Test\1.c(40) : warning C4013: 'GreaterFromHead' undefined; assuming extern returning int
执行 cl.exe 时出错.
Test.exe - 1 error(s), 0 warning(s)
怎么改,求大神帮忙改
追答ElemType data;这句话是书上的的原话,是伪代码,你自己要设置data的数据型,比如int、char
elemtype的英文意思是指元素的类型,要自己设置去。不知道你懂么