#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
void test01()
{
// 子串
string str = "Hello";
string Substr = str.substr(1, 3);
cout << "Substr = " << Substr << endl;
}
// 实际操作
void test02()
{
string email = "heima@qq.com";
int pos = email.find("@");
cout << "pos = " << pos << endl;
//输出邮箱@前的信息
string username = email.substr(0, pos);
cout << "username = " << username << endl;
}
int main()
{
//test01();
test02();
system("pause");
return 0;
}
(6)string-子串
最新推荐文章于 2024-03-30 19:29:15 发布