求助c语言报错

#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)

#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
int 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;
}
你的int data没设置数据类型,其他没得问题追问

怎么改,求大神帮忙改

追答

ElemType data;这句话是书上的的原话,是伪代码,你自己要设置data的数据型,比如int、char

elemtype的英文意思是指元素的类型,要自己设置去。不知道你懂么

温馨提示:答案为网友推荐,仅供参考
第1个回答  2021-01-15
#include <stdio.h>
#include <string.h>
int main()
{

int gg(int i);
int i;
while(1){
i=0;
printf(" 1.查看历史日程表\n");
printf(" 2.输入新的日程表\n");
printf(" 3.查看已完成的日程表\n");
printf(" 4.查看未完成的日程表\n");
printf(" 5.退出登录\n");
printf(" 请选择相应序号: ");
scanf("%d",&i);
if(i==5){
break;
}
gg(i);
printf("\n");
printf("\n");
printf("\n");
}
}
int gg(int i){
int aa();
int bb();
int cc();
int dd();

switch(i){
case 1:
aa();break;
case 2:
bb();break;
case 3:
cc();break;
case 4:
dd();break;
}
}
int aa(){
FILE*fp;
int length=1000;
char str[1001];
if((fp=fopen("11s.txt","r"))==NULL){
printf("无文件");
return 0;
}
while(fgets(str,length,fp)!=NULL){
printf("%s",str);}
return 1;

fclose(fp);
}
int bb(){
FILE*fp;
char str[400];
printf("内容如下:\n");
scanf("%s",str);
if((fp=fopen("11s.txt","a+"))==NULL){
printf("文件不存在");
return 0;
}

fputs("\n",fp);
fputs(str,fp);
printf("加入成功");
fclose(fp);
return 1;
}
int cc(){
FILE*fp;
int length=1000;
char str[1001];
printf("内容如下:\n");
if((fp=fopen("11s.txt","r"))==NULL){
printf("无文件");
return 0;
}
while(fgets(str,length,fp)!=NULL){
if(strstr(str,"已完成")!=NULL){
printf("%s",str);
}
}
fclose(fp);
return 1;
}
int dd(){
FILE*fp;
int lenght=1000;
char str[1001];
printf("内容如下:\n");
if((fp=fopen("11s.txt","r"))==NULL){
printf("无文件");
return 0;
}
while(fgets(str,lenght,fp)!=NULL){
if(strstr(str,"未完成")!=NULL){
printf("%s",str);
}
}
fclose(fp);
return 1;
}
第2个回答  2014-09-19
this改为this_。
相似回答