#include <iostream>
using namespace std;
#include <string>
void test01 ()
{
string s = "abcdefg";
string subStr = s.substr(1, 3);
cout << subStr << endl;
}
void test02 ()
{
string email = "hello@163.com";
int pos = email.find("@");
string name = email.substr(0, pos);
cout << name << endl;
}
int main ()
{
test01();
test02();
return 0;
}
总结:
灵活运用求子串功能,可以在实际开发中获取有效的信息。