求助 C语言顺序表问题
题目是 输入的数字逆序输出
#include<stdio.h>
#define MAXLEN 100
typedef int DataType;
typedef struct
{ DataType data[MAXLEN];
int Length;
}SeqList;
SeqList L;
void InitList( SeqList *L)
{
L->Length=0;
}
void CreateList(SeqList *L,int n)
{
int i;
printf("输入%d个整数: ",n);
for (i=0;i<n;i++)
scanf("%d",&L->data[i]);
L->Length=i;
}
int GetElem(SeqList *L,int i,DataType *x)
{
if(i<1||i>L->Length)
return 0;
else
{ *x = L->data[i-1];
return 1;
}
}
void DispList(SeqList *L)
{
int i;
for(i=L->Length;i>=0;i--)
{
printf("%5d",L->data[i]);
}
}
main()
{
SeqList L;
InitList(&L);
CreateList(&L,5);
DispList(&L);
}

这是devc里面运行的样子,前面多了个0,在vc6.0里面运行时,0变成 -858993460,我去查了这个数字,查到的说是数组越界相关的问题 ,但是没找到解决方法,求助大佬,帮忙看看
相关推荐
C语言顺序表的实现代码
主要为大家详细介绍了C语言实现顺序表的实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
c语言实现顺序表的基本操作
数据结构顺序表操作 代码如下:#include <stdio>#include <stdlib>#include <malloc>#define LIST_INIT_SIZE 100#define LISINCREMENT 10#define ElemType int#define Status inttypedef struct Sq{ ElemType *elem; int length; int listsize;}SqList;Status InitList(SqList *L){ L->elem=(ElemType*)malloc(LIST_INIT_SIZE*size
顺序表的基本操作C语言
序表的基本操作 初始化、插入、删除、修改、合并、定位
数据结构 顺序表的插入与删除算法的C语言实现
数据结构 顺序表的插入与删除算法的C语言实现,该文档与《数据结构(C语言版)》相配套,基于课本实例
数据结构C语言完成顺序表基本操作
数据结构C语言完成顺序表基本操作,上数据结构课的时候的任务,可以在vs上实现,用switch函数选择


