I am trying to take the words from output and find any word with the letter Q in it. If the word does, it needs to be replaced by the word "bad". After that, I am trying to append each word to output2. I am having trouble doing this. The error I get when I compile is:
invalid conversion from 'const char*' to 'char' [-fpermissive]
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
string manipulate(string x);
int main(int argc, char* argv[])
{
string input, temp, output, output2, test, test2;
int b;
cout << "Enter a string: ";
getline(cin, input);
istringstream iss(input);
while (iss >> test)
{
if(test.length() != 3)
{
test.append(" ", 1);
output.append(test);
}
}
istringstream iss2(output);
while (iss2 >> test2)
{
for(int i = 0; i<test2.length(); i++)
{
switch(test2[i])
{
case 'q':
test2[1]="bad";
output2.append(test2);
break;
}
}
}
cout << "Your orginal string was: " << input << endl;
cout << "Your new string is: " << output2 << endl;
cin.get();
return 0;
}
See Question&Answers more detail:os