练习 6-3 编写一个交叉引用程序,打印文档中所有单词的列表,并且每个单词还有一 个列表,记录出现过该单词的行号。对 the、and 等非实义单词不予考虑。

#include
#include
#include
#include


#define MAXWORD 100

/*Author Stat:  founded 2017 11 26*/
static int count_line = 1;


struct line{
   int line;
   struct line *next;
};


struct tnode{
   char *word;
   struct line *start;
   struct tnode *next;
};


struct tnode *addItem(struct tnode *,char *);
struct line *addlines(struct line *);
void showItem(struct tnode *);
void showLine(struct line *);
struct tnode *Ialloc(void);
struct line *Lalloc(void);
char *walloc(char *);
int getword(char *,int);
int Nonrealword(char *);


int main(void)
{
   struct tnode *head;
   char word[MAXWORD];


   head = NULL;
   while(getword(word,MAXWORD) != EOF)
      if(Nonrealword(word))
         if(isalpha(word[0]))
       head = addItem(h

你可能感兴趣的:(CLanguageCode,练习6-3)