My first post here!
For this problem, I have to have two text files: one for list of words that need to be found and other containing the document that needs to be search. The results would placed in a output "results" file later one.
What I've Done: I've already figured out a way to store all of the word list onto an array.
Current Problem: How to find words that are the same and to increment the counter every time it is found.
- For this, a “word” is simply a string of characters delimited by white space. Punctuation shouldn't matter.
- Capitalization does matter
- Format should be like this:
By "capitalization does matter", do you mean that "HELLO" is a different word from "hello"? If you mean that they are the same word, then capitalization does not matter.
Are you allowed to use std::map? This would make your life a lot easier: just have the words be the keys and the count be the values - e.g. std::map<std::string, int>
If you can't use it, you will probably be forced to use parallel arrays. In that case you will need to consider what happens when there are more unique words than slots in your arrays.
Do not loop on eof, like you do on line 49. Loop on the input operation: while(inFile2 >> words)
To search for words in the other file:
- read individual words from the file
- loop through your stored words and compare to the word you just read
- if they match, you have a match