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;
}

最新文章

  1. [翻译]AKKA笔记 -ACTOR SUPERVISION - 8
  2. pycharm 调试 django 应用
  3. [课程设计]Scrum 1.7 多鱼点餐系统开发进度(点餐菜式内容添加及美化)
  4. ListView自定义适配器--10.17
  5. [转]《深度探索C++对象模型》读书笔记[二]
  6. Servlet实现文件的下载
  7. xls与csv文件区别?
  8. const关键字详解
  9. javaScript执行环境、作用域链与闭包
  10. 推荐几个IDEA插件,Java开发者撸码利器。
  11. 使用 NLog 给 Asp.Net Core 做请求监控
  12. Springboot+Mybaits之两张表同时插入数据
  13. Atitit s2018 s3 doc list alldvc.docx&#160;.docx s2018 s3f doc compc s2018 s3f doc homepc sum doc dvcCompc dtS312 s2018 s3f doc compc\Atitit PathUtil 工具新特性新版本 v8 s312.docx s2018 s3f doc compc\Atitit 操作日
  14. python第二章(2)列表
  15. 谷歌(Google)被墙,解决地图和字体无法显示的问题
  16. 'Newtonsoft.Json' already has a dependency defined for 'NETStandard.Library'
  17. ural 2032 Conspiracy Theory and Rebranding (数学水题)
  18. HDUOJ---1233还是畅通工程
  19. Solr4.6删除数据的办法
  20. ZJOI 2009 假期的宿舍 最大匹配

热门文章

  1. libvirt log系统分析
  2. nodejs加解密
  3. 记录解决一个项目中遇到的maven打包问题
  4. 【Python】【demo实验16】【练习实例】【打印所有水仙花数】
  5. SQL Server 验证身份证合法性函数(使用VBScript.RegExp)
  6. 输出1-n的全排列dfs
  7. 剑指offer2:C++实现的替换空格(字符中的空格替换为“%20”)
  8. Kefa and Dishes(CodeForces580D)【状态压缩DP】
  9. curl put方式上传文件
  10. MySql 枚举和集合 详解