string::append
string (1) |
string& append (const string& str); |
---|---|
substring (2) |
string& append (const string& str, size_t subpos, size_t sublen); |
c-string (3) |
string& append (const char* s); |
buffer (4) |
string& append (const char* s, size_t n); |
fill (5) |
string& append (size_t n, char c); |
range (6) |
template <class InputIterator> |
initializer list(7) |
string& append (initializer_list<char> il); |
using namespace std;
int main()
{
string s1 = "abc";
string s2 = "def";
s1.append(s2);
cout << "1 " << s1 << endl;
string s3 = "ghi";
try{
s1.append(s3, 4, 3);
}catch(out_of_range){
cout << "out_of_range" << endl;
}
cout << "2 " << s1 << endl;
const char *s4 = "hello";
s1.append(s4);
cout << s1 << endl;
const char *s5 = "weather";
s1.append(s5, 3);
cout << s1 << endl;
s1.append(5, '$');
cout << s1 << endl;
string s6 = "12345";
s1.append(s6.begin() + 1, s6.end() - 2);
cout << s1 << endl;
initializer_list<char> s7 = {'q', 'w', 'e', 'r'};
s1.append(s7);
cout << s1 << endl;
return 0;
}
string::append的更多相关文章
- C++ string append方法的常用用法
append函数是向string的后面追加字符或字符串. 1).向string的后面加C-string string s = “hello “; const char *c = “out here “ ...
- C++ string append()添加文本
C++ string append()添加文本 1. C++ string append()添加文本 使用append()添加文本常用方法: 直接添加另一个完整的字符串: 如str1.append( ...
- std::string::append函数
string& append (const string& str); string& append (const string& str, size_t subpos ...
- 为什么operator>>(istream&, string&)能够安全地读入长度未知的字符串?
一般而言,实现"读入用户输入的字符串",程序中自然不能对用户输入的长度有所限定.这在C++中很容易实现,而在C中确没那么容易. 这一疑问,我在刚学C++的时候也在脑中闪现过:不过很 ...
- 标准C++中的string类的用法总结
标准C++中的string类的用法总结 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用.但是如果离开了MFC框架,还有 ...
- How to: Convert Between Various String Types
This topic demonstrates how to convert various Visual C++ string types into other strings. The str ...
- c++:string函数
string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化此外,string类还支持 ...
- C++中string,wstring,CString的基本概念和用法
一.概念 string和CString均是字符串模板类,string为标准模板类(STL)定义的字符串类,已经纳入C++标准之中.wstring是操作宽字符串的类.C++标准程序库对于string的设 ...
- C++ STL string
要想使用标准C++中string类,必须要包含 #include <string>// 注意是<string>,不是<string.h>,带.h的是C语言中的头文件 ...
随机推荐
- CF792E Colored Balls【思维】
题目传送门 考试的时候又想到了小凯的疑惑,真是中毒不浅... 设每一个数都可以被分成若干个$k$和$k+1$的和.数$x$能够被分成若干个$k$和$k+1$的和的充要条件是:$x%k<=floo ...
- Guava源码阅读-io-Files
package com.google.common.io; 今天阅读一个非常常用的类Files,文件操作类. readLines(File file, Charset charset),这个方法将Fi ...
- SQuirreL连接Phoenix报java.util.concurrent.TimeoutException
1.表象 java.util.concurrent.TimeoutException at java.util.concurrent.FutureTask.get(FutureTask.java:20 ...
- Spring+SpringMvc+Hibernate整合记录
Spring+SpringMvc+Hibernate+Maven整合各大配置文件记录 1.Idea新建的Maven架构 2.Maven的对象模型的内容 <project xmlns=" ...
- Postfix to Prefix Conversion & Prefix to Postfix Conversion
Postfix to Prefix Conversion Postfix: An expression is called the postfix expression if the operator ...
- Select 多个表并且相关联转置
已知一个表的结构为: ------------------- 姓名 科目 成绩 张三 语文 20 张三 数学 30 张三 英语 50 李四 语文 70 李四 数学 60 李四 英语 90 怎样通过 ...
- 链表操作Java实现
单链表 存储结构 public class ListNode { int i; ListNode next; ListNode(int i) { this.i = i; } public String ...
- 使用winsw包装服务将nginx包装为Windows服务
**Nginx本身在Windows上并不支持以服务的形式运行,官方文件中有提到.http://nginx.org/en/docs/windows.html,所以在Windows下使用winsw将Ngi ...
- PAT B1022 D进制的A+B
课本AC代码 #include <cstdio> int main() { int a, b, d; scanf("%d%d%d", &a, &b, & ...
- 在 jupyterlab 和 jupyter notebook 中集成conda虚拟环境
在jupyterlab中切换虚拟环境使用jupyter-conda包,参考链接:https://pypi.org/project/jupyter-conda/ Install Requirements ...