例子

 1C++中获得string的子串#include <iostream>
 2C++中获得string的子串#include <string>
 3C++中获得string的子串
 4C++中获得string的子串using namespace std;
 5C++中获得string的子串int main()
 6}

   
  结果   if

basic_string   substr(size_type   pos   =   0,        size_type   n   =   npos)   const;  
  The   member   function   returns   an   object   whose   controlled   sequence   is   a   copy   of   up   to   n   elements   of   the   controlled   sequence   beginning   at   position   pos.  

 

substr(start,length);

带两个参数,第一个是子串的起始位置(从0开始),第二个是子串的长度

 

相关文章:

  • 2021-09-29
  • 2021-11-26
  • 2021-07-05
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2021-10-13
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案