How to delete charcter from string in c++?

i am doing a question ,i need to delete all the charcters at even places ,my question is how to delete those charcters and update the string ?

Example:- string given CHAMPIONSHIP
output- HMINHP

void change(string &real){string temp;for(int i=1;i<real.size();i+=2)temp+=real[i];swap(real,temp);}

1 Like

without using pointers is it possible .i like this approach but pointers and adresses , i am not comfortable with them.i am always confused with them.but thank you @nvdrag_123

His approach does not use pointers (at least, not directly) :slight_smile:

lol but adress of real is used and pointers and adresses confuse me a lot ,i don’t know why ?

Not exactly: real is passed in by reference - its address is not taken.


oh got it bro

1 Like