+ 26
how do i erase letters from string from the position of the previously erased letter?
if the end of the string is reached, the index restarts at 0. the last character that stands the process should be retained
3 odpowiedzi
+ 3
u can erase letters with the erase() function takes 2 parameters, first one where to start and second one how many letters to erase,
std::string hey = "hey";
hey.erase(0, 1); // now variable hey is equal to "ey"
+ 24
here's my code. it doesn't work.
#include <iostream>
using namespace std;
int main() {
string str="FLAMES";
int x=1, pos=0, limit=10;
while(str.size()>1){
if(x==limit){
str.erase(pos,1);
x=1;
}
if(pos>=str.size()){
pos=0;
}
x++;
pos++;
cout<<str<<endl;
}
return 0;
}
+ 1
what errors it gives u