Hello,
What I had to do in the code is to define the function seperateWords so that it separates whole sentences/phrases. For instance "I need help" would come out as "I","need","help".
Could anyone please find the faults in the following solution?
Code:Given: #include <iostream> using namespace std; int main (void) { vector<string> lines, words; lines.push_back("Darth Archos"); lines.push_back("is the"); lines.push_back("Lord of the Sith"); words = seperateWords(lines); cout << "The seperated words are:" << endl; for (unsigned i = 0; i < words.size(); i++) { cout << words[i] << ", "; } cout << endl; return 0; } vector <string> seperateWords (vector<string> lines) { vector<string > words; //Separating stuff goes here string toFind = " "; //find whitespace string replaceWith = "\n"; //replace with new line } for(unsigned i=0;i < lines.size(); i++) //loop through first string { << lines[i] //read from first string words.push_back('str[i]') //add to string "words" } for(unsigned x=0;x < lines.size(); x++) //loop through second string { << lines[x] //read from second string words.push_back(str[x]) //add to string "words" { for(unsigned y=0;y < lines.size(); y++) //loop through third string { << lines[y] //read from third string words.push_back(str[y]) //add to string "words" } return words; }