看错在哪里,怎么改
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
typedef struct alist{
int n;
int maxsize;
int score[10]; //arry
};
typedef struct allist *List;
List ListInit(int size);
int ListEmpty(List L);
int ListLength(List L);
int ListRetrieve(int k ,List L);
int ListLocate(int x,List L);
void ListInsert(int k, int x, List L);
int ListDelete(int k,List L);
void PrintList(List L);
List ListInit(int size){
List L= malloc(sizeof * L);
L -> score= malloc(sizeof(int));
L -> maxsize =size;
L -> n=0;
return L;
}
int ListEmpty(List L){
return L -> n == 0;
}
int ListLength(List L){
return L -> n;
};
int ListLocate(int x,List L){
int i;
for(i=0;i< L->n; i++)
if(L -> score[i] == x ) return ++i;
return 0;
}
int ListRetrieve(int k,List L){
if(k<1|| k> L->n) Error("out of bounds");
return L-> score[k-1];
}
void ListInsert(int k,int x ,List L){
int i;
if(k<0 || k >L->n)Error("out of bounds");
if(L->n== L-> maxsize)Error("out of bounds");
for(i= L->n-1; i>=k; i--)L->score[i+1] =L->score[i];
L->score[k]=x;
L->n++;
}
int ListDelete(int k,List L){
int i;int x;
if(k<1 || k>L->n)Error("out of bounds");
x=L ->score[k-1];
for(i=k;i< L-> n; i++)L->score[i-1]=L->score[i];
L->n--;
return x;
}
void printList(List L)
{
int i;
for(i=0;i<L->n;i++) ItemShow(L->score[i]);
}
--------------------配置: mingw5 - LIB Debug, 编译器类型: MinGW--------------------
检查文件依赖性...
正在编译 D:\C\list_arry\List_arry.c...
[Warning] D:\C\list_arry\List_arry.c:9: warning: useless keyword or type name in empty declaration
[Error] D:\C\list_arry\List_arry.c:22: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:23: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:24: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:25: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:30: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:33: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:38: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:39: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:44: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:45: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:50: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:51: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:51: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:52: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:52: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:52: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:53: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:54: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:58: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:59: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:60: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:60: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:60: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:61: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:69: error: dereferencing pointer to incomplete type
[Error] D:\C\list_arry\List_arry.c:69: error: dereferencing pointer to incomplete type
[Warning] D:\C\list_arry\List_arry.c:70:2: warning: no newline at end of file
构建中止 List_arry: 26 个错误, 2 个警告
C struct
[解决办法]
List L= malloc(sizeof * L);
//改为
List L = malloc(sizeof(alist));
//或者
List L;
L = malloc(sizeof(*L));