C++ string 类中substr的使用方法


 
  
#include
using namespace std;
int main()
{
    string x="Hello_World";
    /*默认截取从0到npos.重载原型为string substr(_off=0,_count=npos);npos一般表示为string类中不存在的位置,_off表示字符串的开始位置,_count截取的字符的数目*/
    cout<源字符串的长度,则子字符串将延续到源字符串的结尾
    */
}
 
  
 
  
 
  
 
 

你可能感兴趣的:(C++)