string子串
功能描述:
从字符串中获取想要的子串
函数原型:
代码如下:
#include <iostream>
using namespace std;
#include <cstring>//string求子串void test01() {string str = "abcdef";string subStr = str.substr(1, 3);cout << "subStr = " << subStr << endl;}void test02() {string email = "hello@sina,com";int pos = email.find("@");string usrName = email.substr(0, pos);cout << usrName << endl;}int main() {test01();cout << "----------------------" << endl;test02();return 0;
}