字符串赋值操作
来源:互联网 发布:linux 命令 选项 编辑:程序博客网 时间:2024/06/05 06:27
&1 相关函数assign的五种初始化方法
- 用常量字符串赋值,下面代码中的str1;
- 直接用另一个字符串赋值,见str2;
- 用一个字符串的前一段子串赋值,str3;
- 用另一个字符串的一个子串赋值,str4;
- 用几个相同的字符,赋值,见str5.
&2 测试源代码
string str1("sophia is a good girl!");
string str2;
string str3;
string str4;
string str5;
str2.assign(str1);
str3.assign("sophia is a good girl!", 8);
str4.assign(str1, 2, 10);
str5.assign(10, 'c');//用几个相同的字符,赋值.
cout << "str1= " << str1 << endl;
cout << "str2= " << str2 << endl;
cout << "str3= " << str3 << endl;
cout << "str4= " << str4 << endl;
cout << "str5= " << str5 << endl;
0 0
- 字符串赋值操作
- bash变量赋值及字符串的操作
- bash变量赋值及字符串的操作
- 字符串赋值
- 字符串赋值
- 字符串的赋值
- 关于字符串赋值
- 给字符串数组赋值:
- string字符串-赋值
- 字符串赋值问题
- 汇编字符串赋值详解
- 宽字符串赋值
- PHP字符串赋值
- 字符串赋值怎么不行
- 字符串 赋值 以及gets
- label赋值属性字符串
- 字符串赋值,查找,交换
- 字符串赋值小知识
- Ajax实现xml文件数据插入数据库(三)---javabean实现数据库插入
- 数论学习之欧几里得的应用
- java反射快速入门(二)
- char,string和CString转换
- 告别2015, 展望2016
- 字符串赋值操作
- 传话
- 从标准输出和读入
- 邮票面值设计
- Android 文件的权限,以及跨应用读取文件
- maven快速入门
- 杭电oj(java版)——1203 I NEED A OFFER!
- 获取当前工作路径和当前模块路径
- 逃跑的拉尔夫