#include <string>
#include <iostream>
using namespace std;
int main()
{
string s;
s = "abcdedf";
//插入
string::iterator it;
s.insert(s.begin(),'1');
cout <<s << endl;
cout <<s.size() << endl;
cout <<s.length() << endl;
//替换,从第三个位置,连续4个位置,替换fan
s.replace(3,4,"fanfanfanfan");
cout << s << endl;
//删除
s.erase(s.begin()+2);
cout << s << s.length() <<endl;
//把s变为空串的方法
s = "";
cout << s.length << endl;
cin.get();
return 0;
}
#include <iostream>
using namespace std;
int main()
{
string s;
s = "abcdedf";
//插入
string::iterator it;
s.insert(s.begin(),'1');
cout <<s << endl;
cout <<s.size() << endl;
cout <<s.length() << endl;
//替换,从第三个位置,连续4个位置,替换fan
s.replace(3,4,"fanfanfanfan");
cout << s << endl;
//删除
s.erase(s.begin()+2);
cout << s << s.length() <<endl;
//把s变为空串的方法
s = "";
cout << s.length << endl;
cin.get();
return 0;
}