//Get the filename.
cout << "Enter the file you wish to have searched:\n";
cin >> filename;
// Open file.
// Read in all the words.
// not really, no
If the words in the file are on different lines, which is usually the case, you read the file line by line and input the words into an array of strings. I propose you use
for reason apparent later.
Now, you create another vector b
of strings to hold distinct words, and another vector c
that serves as a counter. You iterate over the elements of a
, if an element is identical to the one before it, increment the corresponding cell in c
, else, push it to b
and push 1
This is the general idea. Try working that out.
HINT: How do you look for a word in the dictionary?