// erase_str.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <string>
#include <algorithm>
#include <iostream>
int main()
{
using namespace std;
string strSample("Hello String! Wake up to a beautiful day!");
cout <<"The origin sample string is :" <<endl;
cout <<strSample <<endl<<endl;
string::iterator iCharS = find( strSample.begin(),strSample.end(),'S' );
cout<<"Erasing character 'S' from the sample string :"<<endl;
if( iCharS != strSample.end() )
{
strSample.erase(iCharS);
}
cout<<strSample<<endl<<endl;
cout<<"Erasing a range between begin() and end() :"<<endl;
strSample.erase(strSample.begin(),strSample.end());
if( strSample.length() == 0 )
{
cout<<"The string is empty"<<endl;
}
getchar();
return 0;
}