69,382
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<stdlib.h>
typedef struct
{
int id;
char *name;
}elem;
typedef struct
{
elem *EE;
int length;
}Sqlist;
Sqlist a;
int InitList_Sq(Sqlist *L) //构造
{
L->EE=(elem *)malloc(10*sizeof(elem));
L->length = 0;
return 1;
}
int ListInsert_Sq(Sqlist *L, elem e) //末端插入
{
elem *q;
q = &(L->EE[L->length]);
*q=e;
++L->length;
return 1;
}
void input()
{
elem temp;
char ch[21];
// temp=(elem *)malloc(sizeof(elem));
printf("请输入id\n");
scanf("%d",&temp.id);
printf("请输入name\n");
scanf("%s",ch);
temp.name=ch;
ListInsert_Sq(&a,temp);
}
void main()
{
InitList_Sq(&a);
input( );
printf("%d,%s",a.EE->id,a.EE->name);
}