主程序如下;
#include "list.h"
#include <stdio.h>
#include <stdlib.h>
struct Node
{
ElementType Element;
Position Next;
};
int main(){
List list= malloc( sizeof( struct Node ) );
Position P=list;
for(int i=0;i<10;i++){
Insert(i,list,P);
P=P->Next;
}
P=list->Next; //注意不是P=list
for(int j=1;j<=10;j++){
printf("%d\n",P->Element);
P=P->Next;
}
if(!IsEmpty(List list))
printf("not empty");
Delete(ElementType 4,List list);
P=list->Next;
for(int j=1;j<=10;j++){
printf("%d\n",P->Element);
P=P->Next;
}
return 0;
}
编译时出错如下:
zoegreen@zoegreen-Lenovo-IdeaPad-Y470:~/桌面$ gcc main.c list.c -o list
main.c: In function ‘main’:
main.c:24:17: error: expected expression before ‘List’
if(!IsEmpty(List list))
^
main.c:27:12: error: expected expression before ‘ElementType’
Delete(ElementType 4,List list);
^
main.c:27:12: error: too few arguments to function ‘Delete’
In file included from main.c:1:0:
list.h:16:14: note: declared here
void Delete( ElementType X, List L );
^
求大神解答~谢谢~