i need help with removing "s" and "tion" properly if i want to input "composition" it should leave me with "composi" but it leaves me with "compo" and if i were to enter a word that starts with an s and doesnt end with an s the word would not be shown. on the other hand if i were to start and end a word with s the s at the end would be deleted like it should. help if you can
int main()
{
cout<<"Enter a series of strings.\n";
int end,end2,end3,end4;
string input;
while(cin>>input)
{
end=input.rfind("ing");
if(end>-1)
{
input=input.substr(0,end);
// cout<<input<<"\n";
}
end2=input.rfind("ed");
if (end2>-1)
{
input=input.substr(0,end2);
// cout<<input<<"\n";
}
end3=input.rfind("s");
if (end3>-1)
{
input=input.substr(0,end3);
//cout<<input<<"\n";
}
end4=input.rfind("tion");
//string last_pos=end4.rfind("s");
if(end4>=-1)
{
input=input.substr(0,end4);
// cout<<input<<"\n";
}
cout<<input<<"\n";
}
}