#include <stdio.h>
#include <string.h>
#include <malloc.h>
int main (void)
{
FILE *text_file, *dict;
char buffer[1][500];
char buf2[300];
char **pdict;
char *word, *pch;
int count=0, count2=0, flag=0;
int i, scan, length, x;
dict=fopen("dict.txt", "r");
if(dict==NULL)
printf("Dictionary failed.\n");
else
{
while((fgets(buffer,500, dict))!=NULL)
{
count++;
}
}
fclose(dict);
pdict=(char**)(malloc(count*sizeof(char*)));
dict=fopen("dict.txt", "r");
if(dict==NULL)
printf("Dictionary failed.\n");
for(x=0; x<count; x++)
{
scan=fscanf(dict, "%s", buffer[0]);
length=strlen(buffer[0]);
pdict[x]=(char*)(malloc(length*sizeof(char)));
strcpy(pdict[x], buffer[0]);
}
text_file=fopen("textfile.txt", "r");
if(text_file==NULL)
printf("Text File failed.\n");
else
{
while((fgets(buf2,300,text_file))!=NULL)
{
count2++;
pch=strtok(buf2," )(\n*?-%+.,!:1234567890\\\"");
while(pch!=NULL)
{
flag=0;
word=_strlwr(pch);
for(i=1;i<count;i++)
{
if(strcmp(pdict[i],word)==0)
{
flag=1;
break;
}
}
if(flag==0)
{
printf("%s\n",word);
}
pch=strtok(NULL," -\n)(*?%!+.,1:234567890\\\"");
}
}
}
fclose(text_file);
return 0;
}