V
Virgo
The code below cout's separate words from file "text.txt".
int main() {
vector<string> words;
ifstream in("text.txt");
string word;
while(in >> word)
words.push_back(word);
for(int i = 0; i < words.size(); i++)
cout << words << endl;
}
Question?
What I should change in this code above if I like split sentence
entered from keyboard.
string s;
getline(cin,s);
int main() {
vector<string> words;
ifstream in("text.txt");
string word;
while(in >> word)
words.push_back(word);
for(int i = 0; i < words.size(); i++)
cout << words << endl;
}
Question?
What I should change in this code above if I like split sentence
entered from keyboard.
string s;
getline(cin,s);