word.h头文件
#ifndef WORD_H_INCLUDED
#define WORD_H_INCLUDED
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include<iostream>
#include<algorithm>
#define LIST_INIT_SIZE 500 /*线性表存储空间的初始分配量*/
#define LISTINCREMENT 10 /*线性表存储空间的分配增量*/
#define FILE_NAME_LEN 20 /*文件名长度*/
#define WORD_LEN 20 /*单词长度*/
#define MaxStrSize 256
#define llength 110 /*规定一行有110个字节*/
#define MaxStr 258
#define WORD 21
typedef struct
{
char word[MaxStr]; /* ch是一个可容纳256个字符的字符数组 */
int length;
} str; /* 定义顺序串类型 */
typedef struct
{
char word[WORD]; /*存储单词,不超过20个字符*/
int count; /*单词出现的次数*/
} danci;
typedef struct{
danci *elem; /*存储空间基址*/
int length; /*当前长度*/
int listsize; /*当前分配的存储容量*/
} sqlist;
char filename[20];
#endif // WORD_H_INCLUDED
主程序: