#include<stdio.h> #include<malloc.h> #include<stdlib.h> #include<string.h> #define ElemType int struct Node{ ElemType date; struct Node* next; }; typedef Node* LinkList; InitList(LinkList *L){ *L=(Node*)malloc(sizeof(Node)); (*L)->next=NULL; } CreatList(LinkList L){ Node* s; char c; int flag=1; while(flag){ printf("请输入一个字符:"); c=getchar(); if(c!=$){ s=(Node*)malloc(sizeof(Node)); s->date=c; s->next=L->next; L->next=s; } else flag=0; } } Show(LinkList L){ if(L->next!=NULL){ printf("%c-->",L->date); } else printf("Over!"); } void main(){ LinkList L; InitList(&L); CreatList(L); ShowList(L); }
出现以下错误:
--------------------Configuration: lianbiao1 - Win32 Debug--------------------
Compiling...
lianbiao1.c
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(12) : error C2143: syntax error : missing '{' before '*'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(14) : error C2143: syntax error : missing ')' before '*'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(14) : error C2143: syntax error : missing '{' before '*'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(14) : error C2059: syntax error : ')'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(14) : error C2054: expected '(' to follow 'L'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(19) : error C2146: syntax error : missing ')' before identifier 'L'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(19) : error C2061: syntax error : identifier 'L'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(19) : error C2059: syntax error : ';'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(19) : error C2059: syntax error : ')'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(19) : error C2449: found '{' at file scope (missing function header?)
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(35) : error C2059: syntax error : '}'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(45) : error C2146: syntax error : missing ';' before identifier 'L'
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(46) : warning C4013: 'InitList' undefined; assuming extern returning int
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(47) : warning C4013: 'CreatList' undefined; assuming extern returning int
d:\java软件\microsoft visual studio\myprojects\book2\lianbiao1.c(48) : warning C4013: 'ShowList' undefined; assuming extern returning int
执行 cl.exe 时出错.
lianbiao1.obj - 1 error(s), 0 warning(s)
LawrenceLam
相关分类