string___assign
#include <iostream>
#include <iterator>
#include <string> int main()
{
std::string s;
// assign(size_type count, CharT ch)
s.assign(, '=');
std::cout << s << '\n'; // "====" std::string const c("Exemplary");
// assign(basic_string const& str)
s.assign(c);
std::cout << c << "==" << s <<'\n'; // "Exemplary == Exemplary" // assign(basic_string const& str, size_type pos, size_type count)
s.assign(c, , c.length()-);
std::cout << s << '\n'; // "Exemplar"; // assign(basic_string&& str)
s.assign(std::string("C++ by ") + std::string("example"));
std::cout << s << '\n'; // "C++ by example" // assign(charT const* s, size_type count)
s.assign("C-style string", );
std::cout << s << '\n'; // "C-style" // assign(charT const* s)
s.assign("C-style\0string");
std::cout << s << '\n'; // "C-style" char mutable_c_str[] = "C-style string";
// assign(InputIt first, InputIt last)
s.assign(std::begin(mutable_c_str), std::end(mutable_c_str)-);
std::cout << s << '\n'; // "C-style string" // assign(std::initializer_list<charT> ilist)
s.assign({ 'C', '-', 's', 't', 'y', 'l', 'e' });
std::cout << s << '\n'; // "C-style"
}
Output:
====
Exemplary==Exemplary
Exemplar
C++ by example
C-style
C-style
C-style string
C-style
string___assign的更多相关文章
随机推荐
- nginx+lua安装配置
1.选定源码目录选定目录 /usr/local/ cd /usr/local/ 2.安装PCRE库cd /usr/local/wget ftp://ftp.csx.cam.ac.uk/pub/soft ...
- ruby安装sass报错解决办法
ERROR: Could not find a valid gem 'sass' (>= 0), here is why: Unable to download data from http:/ ...
- 学习CSS了解单位em和px的区别
这里引用的是Jorux的“95%的中国网站需要重写CSS”的文章,题目有点吓人,但是确实是现在国内网页制作方面的一些缺陷.我一直也搞不清楚px与em之间的关系和特点,看过以后确实收获很大.平时都是用p ...
- file_get_contents和curl对于post方式的解决办法
post方式解决办法 其实很简单,我们只要仔细看看就知道了... file_get_contents: $content=$_POST['content'];$access_token=$_POST[ ...
- salesforce 零基础学习(六十八)http callout test class写法
此篇可以参考: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restfu ...
- Reflux中文教程——概览
翻译自github上的reflux项目,链接:https://github.com/reflux/refluxjs 〇.安装及引入 安装: npm install reflux 引入: var Ref ...
- error C4996: 'swprintf': swprintf has been changed to conform with the ISO C standard,set _CRT_NON_CONFORMING_SWPRINT
在VS2013上运行一个简单程序时,出现了error C4996: 'swprintf': swprintf has been changed to conform with the ISO C st ...
- !function 笔记
一般看JQuery插件里的写法是这样的 (function($) { //... })(jQuery); 今天看到bootstrap的javascript组件是这样写的 !function( $ ){ ...
- 1129: 零起点学算法36——3n+1问题
1129: 零起点学算法36--3n+1问题 Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 4541 ...
- Oracle to_date函数
TO_DATE格式(以时间:2007-11-02 13:45:25为例)Year: yy two digits 两位年 显示值:07yyy three di ...