Storing all words of a text file & its occurances

Score
0
Vote Up
January 30, 2012 at 21:21:17 Pacific
Specs: Windows 7

I am trying to store all words in a text file into a hash table which also keeps count of occurrences of the word. For a previous assignment I had to just find a specific word in a file. I am trying to tweak this to include a hash table, but I am not familiar with them as well.

#include<stdio.h>
#include<string.h>
main()
{
char *myword = "void";
char word[100];
FILE *src, *dest;
src = fopen("source.txt", "r");
dest = fopen("dest.txt", "w");
while(fscanf(src, "%s", word) > 0)
{
if(strcmp(word, myword) == 0)
fprintf(dest, "%s ", strupr(word));

else
fprintf(dest, "%s ", word);
}
fclose(src);
fclose(dest);
remove("source.txt");
rename("dest.txt", "source.txt");
}


Reply ↓  Report •

Reply to Message Icon Start New Discussion
Related Posts

« Filter Xcopy containing t... Making a batch file to ch... »