#include<stdio.h>
#include<stdlib.h>
typedef int ElemType;
struct Sqlist
{
ElemType* elem;
int length;
int listsize;
}Sqlist
void InitList(Sqlist &L) 为什么老出现error: expected initializer before 'void'|
{
L.elem=(ElemType*)malloc(100*sizeof(ElemType));
if(!L.elem)
printf("ERROR");
L.length=0;
L.listsize=100;
}
int ListAdd(Sqlist &L,ElemType n)
{
int *q=&(L.elem[L.length]);
*q=n;
++L.length;
return 0;
}
void ListGet(Sqlist &L)
{
int x=L.length;
if(L.length<0)
printf("ERROR");
while(L.length>0)
{
L.length--;
printf("%d",L.elem[L.length]);
}
}
int getlength(Sqlist &L)
{
return L.length;
}
int main()
{
int n;
Sqlist sqlist;
InitList(sqlist); error: 'InitList' was not declared in this scope|
while(!scanf("%d",&n))
{
ListAdd(sqlist,n);
}
printf("%d",getlength(sqlist));
ListGet(sqlist);
return 0;
}
以上两处错误该如何让修改