69,336
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW -2
#define MAXKEYNUM 2500 //引索表的最大容量--
#define MAXLINELEN 500 //数目串的最大长度 缓冲区长度--
#define MAXWORDNUM 10 //词表的最大容量--
#define MAXWORDLEN 100//关键词的最大容量--
typedef int Status;
typedef struct{
char *ch;
int length;
}Hstring;
typedef struct{
char *item[MAXWORDNUM];
int last;
}Wordlisttype; //词表类型
typedef int Elemtype;
typedef struct Lnode{
Elemtype data[3];
struct Lnode *next;
}Lnode,*Link,*Linklist;//*号放在前边
typedef struct{
Hstring key;//关键词
Linklist bnolist;//存放书号索引的链表
}Idextermtype;//索引项类型
typedef struct {
Idextermtype item[MAXKEYNUM+1];
int last;
}Idexlisttype;
Idexlisttype idxlist;
void Initidxlist(Idexlisttype *idxlist);
void Init_Hstring(Hstring *wd);
Status Initlist(Linklist *L);
int main()
{
Initidxlist(&idxlist);
return 0;
}
Status Initlist(Linklist *L)
{
int ct;
if(!(*L = (Link)malloc(sizeof(Lnode))))
return OVERFLOW;
for(ct=0;ct<3;ct++)
if(!((*L)->data[ct] = (int)malloc(sizeof(int))))
return OVERFLOW;
(*L)->next = NULL;
return OK;
}//initlist;
void Init_Hstring(Hstring *wd)
{
int ct;
wd->ch = (char *)malloc(MAXWORDLEN*sizeof(char));
for(ct=0;ct<MAXWORDLEN;ct++){
wd->ch[ct] = '\0';
}
wd->length = 0;
}
void Initidxlist(Idexlisttype *idxlist)
{
int ct;
for(ct=0;ct<MAXKEYNUM;ct++){
Init_Hstring(&(idxlist->item[ct].key));
Initlist(&idxlist->item[ct].bnolist);
}
printf("????????????\n");
if(idxlist->item[0].bnolist->next==NULL)//--------------------------------这里有问题
printf("????????????\n");
idxlist->last = 0;
}