#include< string >
string子串
功能描述:
从字符串中获取想要的子串
string substr(int a, int b) const; //返回由pos开始的n个字符组成的字符串
注意并非是从a到b,而是从a开始长度为b的子串
//子串
void test01()
{
string str = "abcdefg";
string subStr = str.substr(1, 3);
cout << "subStr = " << subStr << endl;
string email = "hello@sina.com";
int pos = email.find("@");
string username = email.substr(0, pos);
cout << "username: " << username << endl;
}
int main() {
test01();
system("pause");
return 0;
}