c++ string操作
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str1("hello");
string str2(" study c++");
string::iterator str_iter = str1.begin();
str1.insert(str_iter,'a');
cout << str1 << endl;
str1.insert(str_iter,3,'b');
cout << str1<< endl;
string::iterator str1_iter1 = str1.begin();
string::iterator str2_iter1 = str2.begin();
string::iterator str2_iter2 = str2.end();
str1.insert(str1_iter1,str2_iter1,str2_iter2);
cout << str1 << endl;
str1 = "hello";
str1.assign(str2);
cout << str1 << endl;
str1.assign(8,'K');
cout << str1 << endl;
str1 = "abcdef";
cout << str1 << endl;
string::iterator str1_iter2 = str1.begin();
str1_iter2++;
str1.erase(str1_iter2);
cout << str1<< endl;
string::iterator str1_iter3 = str1.end();
str1_iter3--;
str1_iter2++;
str1_iter2++;
str1.erase(str1_iter2,str1_iter3);
cout << str1 << endl;
str1.insert(0, 3, 'K');
cout << str1 << endl;
str1 = "hello";
str1.insert(5, str2);
cout << str1 << endl;
system("pause");
return 0;
}
=================================================
ahello
bbbahello
study c++bbbahello
study c++
KKKKKKKK
abcdef
acdef
acdf
KKKacdf
hello study c++
请按任意键继续. . .
c++ string操作的更多相关文章
- SHell string操作 转
本文也即<Learning the bash Shell>3rd Edition的第四章Basic Shell Programming之读书笔记之二,但我们将不限于此. String操作 ...
- Linq无聊练习系列8---开放式并发事务,null和 DateTime,string操作练习
/*********************开放式并发事务,null和 DateTime,string操作练习**********************************/ //所谓并发,就是 ...
- 顺序容器----顺序容器操作,vector对象如何增长,额外的string操作,容器适配器
一.顺序容器操作 1.向顺序容器添加元素 向顺序容器(array除外)添加元素的操作: 操作 说明 c.push_back(t) 在c的尾部创建一个值为t的元素.返回void c.emplace_ba ...
- Redis一(Redis-py与String操作)
Redis 介绍 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(so ...
- Redis源码之String操作
0.前言 String操作是Redis操作中最基本的类型,包含get,set,mget,mset,append等等.下面我们会具体分析下一些命令的详细流程,特么简单的命令没有列出. 1.SET命令 2 ...
- string操作
常用的功能测试: #! -*- coding:utf-8 -*- import string s = 'Yes! This is a string' print '原字符串:' + s print ' ...
- openresty开发系列18--lua的字符串string操作
openresty开发系列18--lua的字符串string操作 string的相关操作 1)string.upper(s)接收一个字符串 s,返回一个把所有小写字母变成大写字母的字符串.print( ...
- ZOJ2006 一道很尴尬的string操作题
ZOJ2006(最小表示法) 题目大意:输出第一个字符串的最小字典序字串的下标! 然后我居然想试一试string的erase的能力,暴力一下,然后20msAC了,尴尬的数据.......... #in ...
- linux的string操作(字符串截取,长度计算)
按指定的字符串截取 1.第一种方法: ${varible##*string} 从左向右截取最后一个string后的字符串 ${varible#*string}从左向右截取第一个string后的字符串 ...
- JSTL中c:forEach循环里的值的substr操作及对String操作的常用API
<c:forEach items="${dataList}" var="item" varStatus="itemStatus"> ...
随机推荐
- httpd源码编译安装
什么是编译安装——编译:将源代码变为机器可执行的代码文件.安装:将可执行文件安装到操作系统里,才可以使用. 一.下载httpd源码包 在官网上下载httpd源码包http://httpd.apache ...
- 04 Windows编程——Unicode
VS 2017下源码 #include<stdio.h> int main() { char ASC_a = 'a'; char *ASC_str = "hello"; ...
- selenium 显示等待wait.until 常用封装 及下拉框的选择操作等
from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait a ...
- 极光推送出现 超时问题:Connect timeout. Please retry later. Error:7
检查之后均没有什么太大的问题, 最后发现出现77这种错误码,有一种可能就是系统的ca包没有更新 包名为 ca-certificates 使用命令 yum install ca-certificates ...
- 0009SpringBoot静态资源访问路径
访问静态资源: 静态资源需要放在哪些路径下才能被访问呢: 通过WebMvcAutoConfiguration.java中 addResourceHandlers()方法查找绑定的路径,一个是通过web ...
- TODO:AppiumTestDistribution--CapabilityManager 类
该类代码详见git:https://github.com/AppiumTestDistribution/AppiumTestDistribution/tree/master/src/main/java ...
- java堆栈信息查看,以及JVM性能查看工具-jconsole+jmap
java-core P487 P515 chapter11,主要讲java的异常,里面很多内容收获良多,之前一直没注意过的. 一,Throwable类获得StackTraceElement ,可进行 ...
- JS基本数据类型和引用数据类型区别
1.栈(stack)和堆(heap) stack为自动分配的内存空间,它由系统自动释放:而heap则是动态分配的内存,大小也不一定会自动释放 2.数据类型 JS分两种数据类型: 基本数据类型:Numb ...
- watch 监控的新旧值一致问题处理
watch 监控的新旧值一致问题处理 http://www.imooc.com/article/details/id/286654
- open_window()到底做了什么?
Hlong MainWndID= (Hlong)m_hWnd; open_framegrabber(, , , , , , , , "default", , -, &Acq ...