C++!! URGENT
I just need this part, ignore fileToWords function in header file
that what my source code looks like;
Header:
Your function will return a vector of WORD structures, where each entry contains the misspelled word, along with a vector of the byte position in the file where the word was encountered. The WORD structure is defined in the header file. For instance, if the word "artcic" (a misspelling of arctic) was found three times in the input stream, there would be one entry in the returned vector, and it would contain data like this word: artic pos: 7, 95, 89 Here's the pseudocode for your function which takes an istream& and two const vector
& parameters (the dictionary and the ignored words) Create the empty results vector Read until end of file (while in) Save current position (in.tellg() ->cast to long Long) If tellg() returns -1 (at end of file) Then Exit the Loop Read next word (in >> word >> ws) Convert to Lowercase, remove punctuation Search the List of misspelLed words (results)->set found If found word Then Add position to result.s ElseIf not found If found word Then ElseIf not found If found word Then (Not misspelled) ElseIf not found Go to top of loop Search the List of excLuded words-found Go to top of Loop Search the dictionary->found Go to top of Loop Create a WORD, populate with word, position Add new WORD to resuLts End Loojp Return results (misspelLed words and their positions) You can do this with a series of nested if else statements. However, the continue statement makes it quite a bit easier. The continue statement will jump back to the top of the loop, much like break jumps out of a loop. You can use continue to avoid a series of if(! found) blocks in your code Your function will return a vector of WORD structures, where each entry contains the misspelled word, along with a vector of the byte position in the file where the word was encountered. The WORD structure is defined in the header file. For instance, if the word "artcic" (a misspelling of arctic) was found three times in the input stream, there would be one entry in the returned vector, and it would contain data like this word: artic pos: 7, 95, 89 Here's the pseudocode for your function which takes an istream& and two const vector& parameters (the dictionary and the ignored words) Create the empty results vector Read until end of file (while in) Save current position (in.tellg() ->cast to long Long) If tellg() returns -1 (at end of file) Then Exit the Loop Read next word (in >> word >> ws) Convert to Lowercase, remove punctuation Search the List of misspelLed words (results)->set found If found word Then Add position to result.s ElseIf not found If found word Then ElseIf not found If found word Then (Not misspelled) ElseIf not found Go to top of loop Search the List of excLuded words-found Go to top of Loop Search the dictionary->found Go to top of Loop Create a WORD, populate with word, position Add new WORD to resuLts End Loojp Return results (misspelLed words and their positions) You can do this with a series of nested if else statements. However, the continue statement makes it quite a bit easier. The continue statement will jump back to the top of the loop, much like break jumps out of a loop. You can use continue to avoid a series of if(! found) blocks in your code