主题:线性表这样初始化可以吗?如果不可以的话,该怎么改?
#include<stdio.h>
typedef int ElemType;
#define INITSIZE 100
#define LISTINCREMENT 10
typedef struct{
ElemType * data;
int length;
int listsize;
}sqlist;
int initlist(sqlist *L){
L->data=(ElemType*)malloc(INITSIZE*sizeof(ElemType));
if(L->data==NULL)
return 0;
L->length=0;
L->listsize=INITSIZE;
return 1;
}
void main(){
sqlist *L;
int i=initlist(L);
printf("%d",i);
}
typedef int ElemType;
#define INITSIZE 100
#define LISTINCREMENT 10
typedef struct{
ElemType * data;
int length;
int listsize;
}sqlist;
int initlist(sqlist *L){
L->data=(ElemType*)malloc(INITSIZE*sizeof(ElemType));
if(L->data==NULL)
return 0;
L->length=0;
L->listsize=INITSIZE;
return 1;
}
void main(){
sqlist *L;
int i=initlist(L);
printf("%d",i);
}