substr () function

int main () 
{ 
  String s ( " abcdefghigklmn " );
  String A s.substr = ( 0 , 5 );      // get the length of the string s starting from the 0th bit string of 5 
  cout << a << endl; 
}

Output abcde

s1 = s.sbustr(pos,n);

Returns a string, n characters are copied from the beginning to the pos s1.

pos default 0, the default value of n is s.size () - pos, pos + if n exceeds the length of the string, it is only copied to the end of s;

If pos exceeds the length of the string, throws an exception

Guess you like

Origin www.cnblogs.com/pacino12134/p/11264866.html