I've been trying to code a program that lets you enter a sentence, or merely a word or letter if desired, and then outputs that string but with all of the consonants replaced. As an example if you enter an "r" the program should output "ror", and it should also replace "b" with "bob". Don't ask me why by the way.
Anyway, somehow the program ***** up, it still runs, but outputs seemingly strange error messages. An an example, this is one of the error messages I got:
Enter a sentence: hejsan
Your sentence, but now translated: tribang::compareic_string::compareeg::compareing::copyejsan
Could someone take a look at my code and help me with finding out what's wrong? Because something clearly is...
the code you posted wasn't compiled, it has errors. getline() isn't used like this, you should either include the cstdio library (not recommended), or ou should use: istream& operator>> ( istream&, string& )
this is the main function as it should be:
1 2 3 4 5 6 7
int main(){
string sentence, ny;
cout << "Enter a sentence: ";
cin>>sentence; //use the overloaded extractor rather than getline.
ny = translator(sentence);
cout << "Your sentence, but now translated: " << ny <<endl;
}
the output is weird, but i don't know what's your point in this program, maybe this is how you want it.