Erase a range of characters using an overloaded version of erase() : string erase « String « C++






Erase a range of characters using an overloaded version of erase()

  
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
    string strSample ("Hello String!");

    strSample.erase (strSample.begin (), strSample.end ());

    if (strSample.length () == 0)
        cout << "The string is empty" << endl;

    return 0;
}
  
    
  








Related examples in the same category

1.string.erase(6,9)
2.Use erase to remove all characters from (and including) location 6 through the end of string1