I'm making a loop that runs through a string of characters and looks for double letters. The searching procedure works fine, e.g. for the input "pepper" it finds one double (a pair of adjacent, identical characters), and for the input "nooob", it finds two pairs. Now, the thing I actually want it to do is to break up these pairs by inserting a couple of characters in between them.
What I've done so far is that I create a new string that's empty, and that fills in the characters from the input string. Whenever (in the loop over the characters from the input) it detects a double (again, the detection works), it should, instead of just adding the two letters, say "pp" to the new resulting string, it should add "pDOUBLEp". My problem is that when I try to make it do that, I get an error about me trying to convert *char to char, which I didn't even know that I did.
Anyway, here's the code:
using namespace std;
cin >> key;
int length = strlen(key);
int i; int j=0; int count=0;
cout << "Total number of doubles: " << count << endl;
cout << "Testing the string: " << prepared << endl;
And the error message when I try to compile:
peder@peder-ThinkPad-X220:~/C++/testing$ g++ prepareTest.cpp
prepareTest.cpp: In function ‘int main()’:
prepareTest.cpp:24:18: error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive]
* Note that in the code I ran to get this I had switched two of the "inserts" for something else, hence only one error.
Does anyone see what's obviously wrong here?