Hello houndbob,
PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
I found the second link to be the most help.
|
A few blank lines would make your code easier to read.
What starts in "main" with the for loop for entering is a problem. There is no way out of the loop. I had to enter ^z to exit, but this left "std::cin" in a failed state.
So when you get to the function "keep_window_open():" "std::cin" is in a failed state and nothing happens in the function. It just returns. As an alternative to what you have you may find this of more use:
1 2 3 4 5
|
inline void keep_window_open()
{
std::cout << "\n\n Press Enter to continue: ";
std::cin.get();
}
|
Not sure if "inline" is worth keeping, but it does work. The "std::cin.get()" will allow just the "Enter" key to be pressed. Whereas yours you have to enter something and then press "Enter".
In "main"
1 2
|
for (string word; cin >> word;)
words.push_back(word);
|
This works, but look at it closely. How do you end this loop? I found that this work better:
1 2 3 4 5 6
|
std::cout << "\n Enter some words. type (end) to quit.\n" << std::endl;
for (string word; cin >> word && word != "end";)
words.push_back(word);
std::cout << std::endl;
|
The last line is to break up the output to the screen.
Also this leaves "std::cin" in a good state that can be used later.
The nested for loops need some work.
As dutch said:
You need to loop through the "disliked" words and compare them to word[i] one at a time. |
The "else" statement is printing out to many words. You do not need the "else" part and the "std::cout" should be at the end of the outer for loop. This is only part of what is needed. You still need a way to print the "BLEEP" and not the word it replaces.
I have made the program work. Now it is your turn to try to make the necessary changes.
Hope that helps,
Andy