C++中substr()详解
#include<string>
#include<iostream>
using namespace std;
int main()
{
string s("12345asdf");
string a = s.substr(,); //获得字符串s中从第0位开始的长度为5的字符串
cout << a << endl;
}
输出如下:
0. 用途:一种构造string的方法
1. 形式:s.substr(pos, n)
2. 解释:返回一个string,包含s中从pos开始的n个字符的拷贝(pos的默认值是0,n的默认值是s.size() - pos,即不加参数会默认拷贝整个s)
3. 补充:若pos的值超过了string的大小,则substr函数会抛出一个out_of_range异常;若pos+n的值超过了string的大小,则substr会调整n的值,只拷贝到string的末尾
C++中substr()详解的更多相关文章
- winxp计算机管理中服务详解
winxp计算机管理中服务详解01 http://blog.sina.com.cn/s/blog_60f923b50100efy9.html http://blog.sina.com.cn/s/blo ...
- cocos2dx常见的46中+22中动作详解
cocos2dx常见的46中+22中动作详解 分类: iOS2013-10-16 00:44 1429人阅读 评论(0) 收藏 举报 bool HelloWorld::init(){ ///// ...
- Android中Context详解 ---- 你所不知道的Context
转自:http://blog.csdn.net/qinjuning/article/details/7310620Android中Context详解 ---- 你所不知道的Context 大家好, ...
- iOS中-Qutarz2D详解及使用
在iOS中Qutarz2D 详解及使用 (一)初识 介绍 Quartz 2D是二维绘图引擎. 能完成的工作有: 绘制图形 : 线条\三角形\矩形\圆\弧等 绘制文字 绘制\生成图片(图像) 读取\生成 ...
- 【转】declare-styleable的使用(自定义控件) 以及declare-styleable中format详解
原文网址:http://www.cnblogs.com/622698abc/p/3348692.html declare-styleable是给自定义控件添加自定义属性用的 1.首先,先写attrs. ...
- Python中dict详解
from:http://www.cnblogs.com/yangyongzhi/archive/2012/09/17/2688326.html Python中dict详解 python3.0以上,pr ...
- 【转】 java中HashMap详解
原文网址:http://blog.csdn.net/caihaijiang/article/details/6280251 java中HashMap详解 HashMap 和 HashSet 是 Jav ...
- java中HashMap详解(转)
java中HashMap详解 博客分类: JavaSE Java算法JDK编程生活 HashMap 和 HashSet 是 Java Collection Framework 的两个重要成 ...
- java集合(2)- java中HashMap详解
java中HashMap详解 基于哈希表的 Map 接口的实现.此实现提供所有可选的映射操作,并允许使用 null 值和 null 键.(除了非同步和允许使用 null 之外,HashMap 类与 H ...
随机推荐
- Linux基础命令、软件安装
常用命令 查看当前系统中存在哪些shell cat /etc/shells [root@** ~]# cat /etc/shells /bin/sh /bin/bash /usr/bin/sh /us ...
- [Codeforces]1263C Everyone is a Winner!
题目 On the well-known testing system MathForces, a draw of nnn rating units is arranged. The rating w ...
- 7.8 Varnish 其他命令
- 嵊州普及Day1T2
题意:走迷宫.求走到a[n][n]需要多久. 考场上想的dfs,听老师说最多50分.代码懒得码了,知道是走迷宫就好. 正解:bfs,时间复杂度O(n). 见代码: #include<iostre ...
- 将git本地仓库同步到远程仓库
同步到远程仓库可以使用git bash 也可以使用tortoiseGit 1.使用git bash 在仓库的所在目录,点击右键选择“Git Bash Here”,启动git bash程序. 然后再gi ...
- 用四种方法将两个AJAX改为同步
用四种方法将两个AJAX改为同步 Promise.Generator函数.yield.async/await 相关 今有一题,题目为: 现有ajax1()和ajax2(),用于快速初始化CODE1和C ...
- idea 将java 项目 打包成jar包
记录一下,防止忘记.ps : 请忽略这个是web项目 1.idea 打包jar包 (1)首先打开Project Structure,选中Artifacts (2)点击绿色加号,选中jar ,然后选中f ...
- Vulkan SDK 之 DrawCube
Waiting for a Swapchain Buffer Beginning the Render Pass Bind the Pipeline Bind the Descriptor Sets ...
- Andriod studio 汉化教程
1.找到安装目录,D:\Program Files\Android\Android Studio\lib,先保存resources_en,并且把它的名字改为resources_cn.jar 2.下载汉 ...
- Mysql 存储过程造测试数据
1.Mysql 存储过程造测试数据 -- 创建一个用户表 CREATE TABLE `sys_user` ( -- `id` CHAR (32) NOT NULL DEFAULT '' COMMENT ...