This is a piece of code that I found online, basically, it helps me to erase all the punctuation in a string.
for(size_t i = 0; i<text.length(); ++i)
if(ispunct(text[i]))
text.erase(i--, 1);
Like in the sentence: "hello, I am John". It will delete the comma. But I do not understand why in the code:
text.erase(i--, 1);
I do not understand why it delete the text[i--](which is o in this case), but when the code run, it works perfectly and does not erase "o". I know that I misunderstand that part. Can somebody explain to me about that?