顺序表的建立
各位大神们,小菜鸟请求代码帮助,以下是我自己构思的代码,编译总出错,这是怎么回事啊,请帮忙细致的解释一下···先谢谢啦··题目是:建立含有n个数据元素的顺序表并输出该表各元素的值,元素的个数及n个元素的值由键盘输入,元素类型为整形。#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define OK 1
#define ERROR 0
#define OVERFLOW 0
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef struct
{
int *elem;
int length;
int listsize;
}Sqlist;
int InitList_Sq(SqList &L)
{
L.elem=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)
exit(OVERFLOW)
L.length=0;
L.listsize=LIST_INIT_SIZE;
return OK;
}
int createList_Sq(SqList &L)
{
int i;
printf("Input the datas:");
for(i=0;i<=L.length;i++)
scanf("%d",&L.elem[i]);
return OK;
}
void main()
{
clrscr();
int i,n;
SqList L;
InitList_Sq(l);
printf("\nInput the length of the List L:");
scanf("%d",&n);
L.length=n;
createList_Sq(L);
printf("OutPut the datas:");
for(i=0;i<=L.length;i++)
printf("%d",L.elem[i]);
}