刚做了个顺序表,程序编译的时候没错,当运行的时候就有错,我估计是结构体指针出了问题,但就是不知道错在哪里,望各位大侠指点!
#include <stdio.h>
#define maxnum 20
typedef int elemtype;
struct qltype
{
elemtype list[maxnum];
int num;
};
void creat(qltype *la) /*建立顺序表*/
{
int i,n;
printf("\n please input the number of node:");
scanf("%d",&n);
la->num=n; //运行到这步就出错
printf("\n Input the content:");
for(i=0;i<n;i++)
{
printf("\n please input the ");
printf("%d",i);
printf("th number:");
scanf("%d",&la->list[i]);
}
for(i=0;i<n;i++)
printf("%d",la->list[i]);
}
int main()
{
struct qltype *la=0;
creat(la);
return 0;
}
[此贴子已经被作者于2007-4-15 14:13:56编辑过]