I need some advice and to be pointed in the right direction on how to use append and erase properly. On an assignment I'm working on, I have to mix around some string data that is laid out in a modified form of pig latin. I have to convert the modified pig latin to english and I can do that for words that begin with vowels but for words with consonants, I'm having issues. Here is an example of what I can't seem to figure out.
Take "ig-pay" and make it "pig", or "anslation-tray" and make it "translation"
Below is my code for the void function I have, which like I said converts words that begin with a vowel easily using the srt.erase function.
Use string::find to locate the '-' (e.g. from "ig-pay"). Then use string::substr to extract the suffix "ig" and latin "pay".
Iterate the latin to retrieve original characters of prefix. Finally combine the prefix and suffix back to word.
Note: temp+word=temp2;
is not legal. You attempt to create a nameless temporary object that holds the result of temp+word, and then assign value of temp2 into that nameless object.
In assignment lhs = rhs; the value of rhs is copied into object lhs.
Ah, thanks for the reply and help. I always forget the order of how copying works. What I intended to do when I was using temp+word = temp2 was concatenate the two values into the temp 2 string, but alas I see where I was wrong.