# Include <stdlib. h> # include <stdio. h> # define max_word 128; # define max_len 100 typedef struct _ key {char * keyword; int cout;} keyword; // initialize keyword keytab [] = {"Auto ", 0, "break", 0, "case", 0, "char", 0, "const", 0, "continue", 0, "default", 0, "Define", 0, "unsigned", 0, "Void", 0, "volatile", 0, "while", 0}; // obtain the length of size_t getlen (void) {return (sizeof keytab/sizeof keytab [0]);} // print void printkey (keyword key [], Size_t Len) {int I; for (I = 0; I <Len; I ++) {printf ("% 4D % s \ n", key [I]. cout, key [I]. keyword) ;}}// obtain the word int getword (char * word, int Len, file * f) from the file {char * w = word; int C; // skip the space while (isspace (C = fgetc (f); If (C! = EOF) * w ++ = C; // If (! Isalpha (c) {* w = '\ 0'; return C ;}for (; -- Len> 0; W ++) {If (! Isalnum (* w = fgetc (F) {ungetc (* w, f); break ;}* W = '\ 0'; return C ;} // Binary Search int binsearch (keyword K [], char * word, int Len) {int low, high, mid, Pos; Low = 0; high = len-1; while (low <= high) {mid = (high + low)/2; // if the word is greater than the key [Mid]. the next cycle of keyword is in [Low ~ If (Pos = strcmp (word, K [Mid]. keyword) <0) {high = mid-1;} else if (Pos> 0) {LOW = Mid + 1;} else {return mid ;}} return-1;} // findkeyw. h // main. C # include <stdio. h> # include <stdlib. h> # include <string. h> # include "findkeyw. H "int main (INT argc, char * argv []) {extern keyword keytab []; size_t Len = getlen (); file * F; if (F = fopen ("findkeyw. H "," R ") {char word [max_len]; int Pos; while (getword (word, Ma X_len, f )! = EOF) {If (isalpha (word [0]) {If (Pos = binsearch (keytab, word, Len)> 0) {keytab [POS]. cout ++ ;}}fclose (f) ;}printkey (keytab, Len); System ("pause"); Return 0 ;}