Javatpoint Logo
Javatpoint Logo

C++ String erase()

This function removes the characters as specified, reducing its length by one.


Consider a string str. Syntax would be:


  • pos :It defines the position of the character which is to be removed.
  • len :It defines the number of characters to be erased.
  • Itr : It is an iterator to the character to be removed.
  • Range(first,last): It defines the range within the string to be removed.

Return value

It returns *this.

Example 1

Let's see a simple example when pos and len are given:


This is java tutorial

Example 2

Let's see a simple example when iterator is passed in a parameter:


java programing

Example 3

Let's see a simple example when the range is mentioned in a parameter:


This is an example of C

Next TopicC++ Strings

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA