#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
string str1 = "hello";
string* str2 = new string("hello");
string str3 = "world";
int length = str1.length();
cout << "调用str.length()函数获取字符串长度:" << length << endl;
cout << endl;
string str4 = str1 + str3;
cout << "字符串连接结果:" << str4 << endl;
cout << endl;
if (str1 < str3)
cout << "字符串比较:" << "str1<str2" << endl;
cout << endl;
string::const_iterator it = str1.begin();
cout << *it << endl;
cout << endl;
it = str1.end();
it--;
cout << *it << endl;
cout << endl;
reverse(str1.begin(), str1.end());
cout << "倒置串:" << str1 << endl;
cout << endl;
string a = "abc123";
const char *b;
b = a.c_str();
cout << "a:" << a << endl;
cout << "b:" << b << endl;
a = "asd456";
cout << "a:" << a << endl;
cout << "b:" << b << endl;
string c = "abc123";
char *d = new char[20];
strcpy(d, c.c_str());
cout << "c:" << c << endl;
cout << "d:" << d << endl;
c = "asd456";
cout << "c:" << c << endl;
cout << "d:" << d << endl;
cout << endl;
string st1("babbabab");
cout << st1.find('a') << endl;
cout << st1.find('a', 2) << endl;
cout << (st1.find('c', 0) == -1) << endl;
cout << (st1.find('c', 0) == 4294967295) << endl;
string st2("aabcbcabcbabcc");
str1 = "abc";
cout << st2.find(str1, 2) << endl;
cout << st2.find("abcdefg", 2, 3) << endl;
cout << st1.rfind('a', 7) << endl;
string str6("bcgjhikl");
string str7("kghlj");
cout << str6.find_first_of(str7, 0) << endl;
string str("abcdecg");
cout << str.find_last_of("hjlywkcipn", 6) << endl;
cout << str.find_first_not_of("kiajbvehfgmlc", 0) << endl;
cout << str.find_last_not_of("kiajbvehfgmlc", 6) << endl;
system("pause");
return 0;
}