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");
}
| « Filter Xcopy containing t... | Making a batch file to ch... » |