定义链表

来源:百度知道 编辑:UC知道 时间:2024/05/31 09:39:48
在学数据结构的链表是遇到了问题,在定义链表是出错了,以下是源代码和出错提示(因为提问的字数限制,出错提示只列出了部分,但是相同类型的),编译环境为VC6.0,请各位帮忙看看是哪错了,小弟在这先行谢谢了.
源代码:
#include "stdio.h"
#include "stdlib.h"

#define List_INIT_SIZE 100
#define LIST_INCREMENT 10

typedef int Elemtype;
typedef struct
{
Elemtype *elem;
int length;
int size;
}SqList;

int InitList(SqList &L)
{
L.elem=(Elemtype)malloc(List_INIT_SIZE*sizeof(Elemtype));
if(!L.elem)
{
exit(OVERFLOW);
}
L.length=0;
L.size=List_INIT_SIZE;
return OK;
}

void DestoryList(SqList &L)
{
if(!L.elem)
{
delete L.elem;
L.elem=NULL;
}
L.length=0;
L.size=0;
}

void ClearList(SqList &L)
{
L.elem=NULL;
L.length=0;
L.size=List_INIT_SIZE;
}

int ListEmpty(SqList L)
{
if(L.length>0)
{
return OK

#include "stdafx.h"

#include "stdio.h"
#include "stdlib.h"

#define List_INIT_SIZE 100
#define LIST_INCREMENT 10
#define OK 1 //你用到了但你没预处理
#define FALSE 0 //你用到了但你没预处理
#define ERROR 0
#define OVERFLOW 0
typedef int Elemtype;
typedef struct
{
Elemtype *elem;
int length;
int size;
}SqList;

int InitList(SqList &L)
{
//L.elem=(Elemtype)malloc(List_INIT_SIZE*sizeof(Elemtype)); //此处类型不匹配,
L.elem=(Elemtype*)malloc(List_INIT_SIZE*sizeof(Elemtype));
if(!L.elem)
{
exit(OVERFLOW);
}
L.length=0;
L.size=List_INIT_SIZE;
return OK;
}

void DestoryList(SqList &L)
{
if(!L.elem)
{
delete L.elem;
L.elem=NULL;
}
L.length=0;
L.size=0;
}

void ClearList(SqList &L)
{
L.elem=NULL;
L.length=0;
L.size=List_I