How to make string shorter?

Hello there, i wanna know how to make string's shorter (or cut letters from the string), there is an example:
1
2
3
4
5
6
7
8
9
string number;
cin >> number;  //input from keyboard, "two"
............... //How to cut the "o"?
                //now the number is "tw"
number += "en";
number += "ty"; //just an example
cout<<number<<endl; //The result is: "twenty"

return 0;


I hope you will understand my example, thanks in advance!
In this case you want to use string's function "erase" - http://www.cplusplus.com/reference/string/string/erase/

the string class has a lot of different functionalities - http://www.cplusplus.com/reference/string/string/

Here are two good videos showing examples of a lot of it's functions -
https://www.youtube.com/watch?v=dSfjBoip4c0&list=PLAE85DE8440AA6B83&index=71
https://www.youtube.com/watch?v=nkKeA74p3RY&list=PLAE85DE8440AA6B83&index=72
Last edited on
that was very simple, thanks a lot, thank also for the links!
Topic archived. No new replies allowed.