C ++ is not familiar with the usage record 1

There are two substr Usage:
Suppose: string s = "0123456789";

string sub1 = s.substr (5); // only one subscript numeral 5 from the beginning until the end of 5: sub1 = "56789"

string sub2 = s.substr (5, 3); // index of from 5 to intercept a length of 3: sub2 = "567"

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

Guess you like

Origin www.cnblogs.com/guohaoyu110/p/11300576.html