substr()函数用法
substr(起始位置,长度)
#include<string>
#include<iostream>
using namespace std;
main()
{
string s("12345asdf");
string a=s.substr(0,4);
//获得字符串s中 从第0位开始的长度为4的字符串
cout<<a<<endl;
}
输出结果为:
1234