1. #include <stdio.h>
  2. #include <regex.h>
  3.  
  4. #define size 1024
  5.  
  6. int main(int argc, char **argv){
  7.     FILE *fp;
  8.     char line[size];
  9.     regex_t re[33];
  10.     int x;
  11.     const char *filename = "enwik8";
  12.     const char *strings[] = {"\bhome\b", "\bdear\b", "\bhouse\b", "\bdog\b", "\bcat\b", "\bblue\b", "\bred\b", "\bgreen\b", "\bbox\b", "\bwoman\b", "\bman\b", "\bwomen\b", "\bfull\b", "\bempty\b", "\bleft\b", "\bright\b", "\btop\b", "\bhelp\b", "\bneed\b", "\bwrite\b", "\bread\b", "\btalk\b", "\bgo\b", "\bstay\b", "\bupper\b", "\blower\b", "\bI\b", "\byou\b", "\bhe\b", "\bshe\b", "\bwe\b", "\bthey\b"};  
  13.  
  14.     for(x = 0; x < 33; x++){
  15.         if(regcomp(&re[x], strings[x], REG_EXTENDED) != 0){
  16.             printf("Failed to compile regex '%s'\n", strings[x]);
  17.  
  18.             return -1;
  19.         }      
  20.     }
  21.  
  22.     fp = fopen(filename, "r");
  23.          
  24.     if(fp == 0){
  25.         printf("Failed to open file %s\n", filename);
  26.    
  27.         return -1;
  28.     }
  29.  
  30.     while((fgets(line, size, fp)) != NULL){
  31.         for(x = 0; x < 33; x++){
  32.             regexec(&re[x], line, 0, NULL, 0);
  33.         }
  34.     }
  35.  
  36.     return 0;
  37. }