- 论坛徽章:
- 0
|
哪位大侠救一下命 吧,我怎么找也找不到错误,但是怎么调就是调不出来,我也不知道错在哪里了,我是一个C语言的初学者。
#define MAXSIZE 100
#define OK 1
#define ERROR 0
#define INCREATSIZE 10
typedef struct { char name[20];/*定义一个结构体*/
int worknumber;}work,*worker;
typedef struct { /*定义一个结构体*/
worker Elem;
int length;
int listsize;}*sqlist;
enterdata(sqlist L){ /*要求输入姓名和号码,输入函数*/
int i;
printf("please enter the worker's total:\n");
scanf("%d",&L->length);
for(i=1;i<=L->length;i++){
printf("the %d worker's name :",i);
scanf("%s",L->Elem.name);
printf("\n");
printf("please enter the %d worker's worknumber:",i);
scanf("%d",&L->Elem.worknumber);
printf("\n");}
}
creatlist(sqlist L){ /*建立顺序表,分配空间*/
L->Elem=(worker)malloc(MAXSIZE*sizeof(work));
if(!L->Elem) exit(ERROR);
L->length=0;
L->listsize=MAXSIZE;
return OK;}
outputlist(sqlist L){ /*输出刚才输入的信息*/
int i;
printf("the worker' data is:\n");
for(i=1;i<=L->length;i++)
printf("%s ",L->Elem.name);
printf("\n");
for(i=1;i<=L->length;i++)
printf("%d ",L->Elem.worknumber);
printf("\n");}
main(){ /*主函数*/
sqlist L1;
creatlist(L1);
enterdata(L1);
outputlist(L1);
}
[ 本帖最后由 sea313081574 于 2006-10-19 21:13 编辑 ] |
|