8.string子串
2021-04-06 本文已影响0人
lxr_
#include<iostream>
using namespace std;
#include<algorithm>
//string求子串
void test0801()
{
string str1 = "abcdef";
string subStr = str1.substr(1, 3);
cout << "subStr=" << subStr << endl;
}
//实用操作
void test0802()
{
string email = "hello@sina.com";
int pos=email.find('@');
string user = email.substr(0, pos);
cout << "user=" << user << endl;
sort(user.begin(), user.end());//升序排序
cout << "user=" << user << endl;
}
int main()
{
test0801();
test0802();
system("pause");
return 0;
}