Sorry for no replies about my created topic I thought I would get email updates on when someone else replied.
I have made a lot of progress on this program. And yes each word weather it be "The" "the." One." One" "one" etc.. is considered a separate word. Punctuation and capitalization keep a two words that are spelled exactly the same from incrementing one another, which is how it is supposed to be. I am able to read two input files, listing the total count of each different word next to it. However, I need to be able to take an input value, say like 10, and only display words that occur at least 10 times in the files. I also need to sort the output list in ascending order but I will worry about that once I can use the input value to display only words occurring a specific number of times.
For better context I am taking 4 arguments when running the program :
Code:
char *inputFileName1 = argv[1];
char *inputFileName2 = argv[2];
char *outputFileName = argv[3];
int wordcount = argv[4];
I need the wordcount argument to be the value that the wordcount has to be greater than or equal to but for now I just want to understand how to display only words that occur based on the chosen wordcount value.
I believe it would fit into this section of code:
Code:
outputFile = fopen (outputFileName, "w+"); //first parameter is input file
if (outputFile == 0)
{
printf ("Failed to open output file.. \n");
return 1;
} else
{
printf ("Successfully opened output file. \n");
}
currentWord = wordptr;
while (currentWord != NULL)
{ //just test currentWord here
//add word name then word count to file, then move to next
fprintf (outputFile, "%s,%d \n", currentWord->str, currentWord->count);
printf ("%s",currentWord->str);
currentWord = currentWord->next;
}
putchar ('\n');
return 0;