#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
void test01()
{
string s1;
s1 = "hello world";
cout<<s1<<endl;
const char *str = "hello world";
string s2(str);
cout<<s2<<endl;
string s3(s2);
cout<<s3<<endl;
string s4(10,'a');
cout<<s4<<endl;
}
void test02()
{
string str1="ddd";
str1+="aaa";
cout<<str1<<endl;
}
void test03()
{
string ls="adadad";
int pos=ls.find("da");
cout<<pos<<endl;
}
void test04()
{
string str1="hello world";
string str2="hello";
cout<<str1.compare(str2)<<endl;
}
void test05()
{
string se="hello world";
for(int i=0;i<se.size();i++)
{
cout<<se[i]<<endl;
}
}
void test06()
{
string str22="hello";
str22.insert(1,"111");
cout<<str22<<endl;
}
void test07()
{
string strw1="helloworld";
string substr=strw1.substr(1,3);
cout<<substr<<endl;
}
void test08()
{
string email="zhangsan@163.com";
int pos=email.find("@");
cout<<pos<<endl;
string name=email.substr(0,pos);
cout<<name<<endl;
}
int main()
{
test02();
test01();
test03();
test04();
test05();
test06();
test07();
test08();
system("pause");
}
