顺序表建立后输出错误的问题

来源:百度知道 编辑:UC知道 时间:2024/05/10 10:17:07
//头文件
#define OVERFLOW 0
#define NULL 0
#define OK 1
#define MAXSIZE 1024
typedef int elemtype;
typedef struct
{elemtype vec[MAXSIZE];
int len;
}sequenlist;
int createsqlist(sequenlist*L,int k)
{int i;
for(i=0;i<k;i++)
scanf ("%d",&L->vec[i]);
return OK;
}
//源程序
#include<stdio.h>
#include"sqlist.h"
void main()
{int i,n;
sequenlist *L,a;
printf("\n Input the length of the list L:\n");
scanf("%d",&n);
L=&a;
L->len=n;
createsqlist(L,n);
printf("Output the list and its length:\n");
for(i=0;i<L->len;i++);
printf("%d",L->vec[i]);
printf("\n This sequenlist's length is %d",L->len);
}
为什么输出顺序表元素时是-858993460??

你也太不小心了吧,for(i=0;i<L->len;i++);这句有没有问题呀!!!?搞得我看了这么久,晕
for语句没有起作用啦1去掉for后的“;”就OK了

你的问题给搞定了也该给我搞一下了吧!!是一个栈的问题,在我的题问里面
这里
http://zhidao.baidu.com/question/14043036.html
我也刚学数据结构,