The program just fails when I run the program could someone point me in the right direction please? I'm a beginner and self teaching myself from a book so I really have no one to ask for help what am I doing wrong???
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
usingnamespace std;
inlinevoid keep_window_open() { char ch; cin >> ch; }
/*
to do list: make a vector of words I want to bleep out, write a loop that scans each word in the vector for the word that the user types in,
if the users word is not a bleeped word then write it if it is then write bleep.
program fails to start up as it is now..
*/
int main() {
vector<string> bleep;
bleep.push_back("bitch"); // would bleep[0] method work better?
bleep.push_back("fuck");
bleep.push_back("shit");
bleep.push_back("damn");
bleep.push_back("hell");
string var;
while (cin >> var){
for (int i = 0; i < bleep.size(); ++i){
if (bleep[i] == var){
cout << " bleep ";
}
else {
cout << " " << var;
}
}
}
}
// standard macro names
#include <iostream>
#include <map>
#include <vector>
usingnamespace std;
int main(){
std::vector <std::string> bleep;
bleep.push_back("bitch"); // Either one goes
bleep.push_back("fuck");
bleep.push_back("shit");
bleep.push_back("damn");
bleep.push_back("hell");
std::vector<std::string>::iterator i; //Loops through everything
std::string q; //The input that gets checked
std::cin >> q;
for(i = bleep.begin(); i != bleep.end(); i++){
if(*i == q){ //i points to everything in the vector of bleep so when you type out a bad word and it equals a place in bleep it prints out if statement
std::cout << "Bleep" << '\n'; //The bleep
} //Everything else goes here. Maybe you can use a template to use your bleeps.
}
}
#include <iostream>
#include <string>
#include <vector>
inlinevoid keep_window_open() { char ch; std::cin >> ch; }
int main() {
// http://www.stroustrup.com/C++11FAQ.html#init-listconst std::vector<std::string> bleep { "bitch", "fuck", "shit", "damn", "hell" };
std::string word ;
while( std::cin >> word ) {
bool bleepable = false ; // start with the premise that the word is not bleepable
for( std::size_t i = 0; i < bleep.size() ; ++i ) { // for each position in the vector
if( bleep[i] == word ) bleepable = true ; // if this word is the same as the one in the vector, it is bleepable
}
// or using an idiomatic range-based loop
// http://www.stroustrup.com/C++11FAQ.html#for
bleepable = false ;
for( std::string bleep_this : bleep ) if( word == bleep_this ) bleepable = true ;
if(bleepable) std::cout << "bleep " ;
else std::cout << word << ' ' ;
}
std::cout << '\n' ;
}