#include"iostream"
#include"string"
// 字符串的提取
using namespace std ;
int main()
{
string str;
str= "Hello this is a little string";
string str2;
// 从第0个到第5个字符串截取给str2
str2 = str.substr(0,5);
cout<<str<<endl;
cout<<str2<<endl;
return 0;
}
使用string.substr(start,end)来截取字符串。