I'm trying to write a loop that searches through an array of characters, and looks for certain combinations. Then if it finds one such combination, say an "abc" within the char array "This is the alphabet: abcdefg...", I need it to simply remove this sequence from the char array, leaving only "This is the alphabet: defg...".
Now, the thing that confuses me is that it successfully DETECTS all these character sequences (I make it print a little line whenever it does, just for control), but removing them, I just can't seem to work out.
What I ended up doing was looping through one char array, and filling every char element from the first into a second (new) char array, UNLESS it notices these sequences, and in that case, I tell it to skip the next 3 or so elements. So roughly, it looks like this:
(first, to remove "abc" from the end of the array. [length is the length of the array])
if(text[length-3]=='a' && text[length-2]=='b' && text[length-1] == 'c')
cout << "Found an abc at the end! Wohoo! " << endl;
The other search-and-delete loops work in the same way, and they all "find" the right stuff, but don't delete anything.
Do you see what I'm doing wrong here?