string::substr
2024-10-06 21:46:43
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;
}
最新文章
- [翻译]AKKA笔记 -ACTOR SUPERVISION - 8
- pycharm 调试 django 应用
- [课程设计]Scrum 1.7 多鱼点餐系统开发进度(点餐菜式内容添加及美化)
- ListView自定义适配器--10.17
- [转]《深度探索C++对象模型》读书笔记[二]
- Servlet实现文件的下载
- xls与csv文件区别?
- const关键字详解
- javaScript执行环境、作用域链与闭包
- 推荐几个IDEA插件,Java开发者撸码利器。
- 使用 NLog 给 Asp.Net Core 做请求监控
- Springboot+Mybaits之两张表同时插入数据
- 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 操作日
- python第二章(2)列表
- 谷歌(Google)被墙,解决地图和字体无法显示的问题
- 'Newtonsoft.Json' already has a dependency defined for 'NETStandard.Library'
- ural 2032 Conspiracy Theory and Rebranding (数学水题)
- HDUOJ---1233还是畅通工程
- Solr4.6删除数据的办法
- ZJOI 2009 假期的宿舍 最大匹配
热门文章
- libvirt log系统分析
- nodejs加解密
- 记录解决一个项目中遇到的maven打包问题
- 【Python】【demo实验16】【练习实例】【打印所有水仙花数】
- SQL Server 验证身份证合法性函数(使用VBScript.RegExp)
- 输出1-n的全排列dfs
- 剑指offer2:C++实现的替换空格(字符中的空格替换为“%20”)
- Kefa and Dishes(CodeForces580D)【状态压缩DP】
- curl put方式上传文件
- MySql 枚举和集合 详解