vendredi 11 septembre 2020

C++ delete duplicates from cstring

I have a c-string that looks something like ABBBCACACACBA and I'm supposed to create a function that deletes the duplicate characters so I end up with ABC. I created a nested for loop that replaces every letter that matches the letter in the outer loop with a \0 and increments a counter that keeps track of the repeats. I'm getting -1 the amount of repeats that should be documented and from checking it spits out ABBC instead of ABC. I'm stumped, any ideas? https://i.imgur.com/WmqAOK1.png

Aucun commentaire:

Enregistrer un commentaire