I'm trying to write a program that "bleeps" out the word "hello", but not other words; that is read in words using cin and print them again using cout. However, if the word is "hello", "BLEEP" should be output instead.
My code is obviously wrong, but I'm not sure how to edit the vector properly. Please help! Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
vector<string>words;
string entry;
string bleep = "hello";
while (cin>>entry)
words.push_back(entry);
if (words() == bleep)
words() = "BLEEP";
cout << "Number of words: " <<words.size() <<endl;
sort(words.begin(),words.end());
for (int i = 0; i< words.size(); ++i)
cout<<words[i] << "\n";