首页 > 其他 > 详细

string::substr

时间:2019-12-19 21:58:44      阅读:88      评论:0      收藏:0      [点我收藏+]
string substr (size_t pos = 0, size_t len = npos) const;

#include <iostream>

#include <string>
using namespace std;
int main()
{
string s1 = "i love lyy, lyy like eat mouse";
string s2 = s1.substr(7, 3);
cout << s2 << endl;
s2 = s1.substr(5);
cout << s2 << endl;
try
{
s2 = s1.substr(50);
}catch(out_of_range)
{
cout << "out_of_range" << endl;
}
cout << s2 << endl;
s2 = s1.substr(s1.length());
cout << s2 << endl;
return 0;
}

string::substr

原文:https://www.cnblogs.com/xpylovely/p/12069577.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!