

2.c
#include<stdio.h>
#define CHR
#define e1 5
typedef char etype;
#include"(2).h"
void main()
{
sqlist *L;
etype a[]={'a','b','c','d','e'};
int len;
initl(L,len);
charu(L,a,e1,len);
displ(L);
//输出表长
printf("%d \n",llen(len));
}

代码如下
2.h
#include<stdio.h>
#include<stdlib.h>
typedef struct sqlist2
{
etype data;struct sqlist2 * next;}sqlist;
int len;
//运算一(初始化)
void initl(sqlist * &L,int len1)
{
L = (sqlist *)malloc(sizeof(sqlist));len1 = 0;}
//插入a,b,c,d,e
void charu(sqlist *&L,etype a[10],int e,int &len1)
{
sqlist *p1,*p2;int i;p1 = L;for(i=0;i<e;i++){p2 = (sqlist *)malloc(sizeof(sqlist));p1->next = p2;p1 = p2;p1->data = a[i];}len1 = i;}
//运算二(销毁)
void destroyl(sqlist * &L,int len1)
{
free(L);len1 = 0;}
//运算三(判空)
bool lempty(sqlist * &L,int len1)
{
return(len1==0);}
//运算四(求表长)
int llen(int len1)
{
return(len1);}
//运算五(输出表)----------------------------------
void displ(sqlist * &L)
{
sqlist *p;p = (sqlist *)malloc(sizeof(sqlist));p = L;while(1){p = p->next;if(p == NULL)break;#ifdef INT
printf("%d ",p->data);#endif
#ifdef CHR
printf("%c ",p->data);#endif
}//putchar('\n');printf("\n");}
//运算六(获得ai)
bool gete(sqlist * L,int j,etype &e,int len1)
{
int i;sqlist *p;if(i<1||i>len1)return false;p = (sqlist *)malloc(sizeof(sqlist));p = L;while(1){i++;p = p->next;if(i>=j){break;}}e = p->data;}
p->data, p->next 初始化了么?