1 #include <iostream>
2 #include<string>//调用string函数库
3 using namespace std;
4 int main()
5 {
6 string s1, s2;//定义两个string类型的变量s1 s2
7 s1 = "c++程序";//对s1变量进行初始化
8 s2 = s1;//对s2变量初始化等于s1
9 string s3;//定义一个string变量
10 cout << "s3=" << s3 << endl;//直接输出变量s3,但是s3的值为空,因此只输出“s3=”
11 s3 = s1 + s2;//初始化s3
12 cout << s1 + s2 << endl;
13 cout << "s3=" << s3 << endl;
14 bool b = s1 < s3;//定义一个布尔类型变量 b 并且用来判断s1<s3,“真”和“假”,是用 0 和非 0 来代表
15 cout << "bool=" << b << endl;
16 char c = s1[2];//定义字符串类型 c 并取s1的第三个 即s1[0,1,2]中的s1[c,+,+]
17 cout << "c=" << c << endl;
18 cout << s1[2] << endl;
19 char arrstr[] = "Hello";
20 s3 = s1 + arrstr;
21 cout << s3 << endl;
22 system("pause");
23 }

最新文章

  1. JMF框架
  2. host 文件
  3. Hbase的配置和安装
  4. JSOI2016R3 瞎BB题解
  5. HDU 1253 (简单三维广搜) 胜利大逃亡
  6. ?--Porg.springframework.beans.MethodInvocationException: Property &#39;username&#39; threw exception; nested exception is java.lang.NullPointerException
  7. 小公司生存,一般活过第一年,就能撑3年(读书笔记:成败关键,关键是你是否拥有现金流客户)good
  8. 全栈project师的毁与誉
  9. CodeForces 484A Bits
  10. JS动态生成&lt;style&gt;
  11. 测试MarsEdit
  12. centos 6.5 搭建ftp服务器
  13. 201521123107 《Java程序设计》第13周学习总结
  14. NOI2001 炮兵阵地
  15. 写markdown博客如何将截图快速上传到图床——记一个工具插件的实现(windows版 开源)
  16. RecyclerView的简单使用
  17. python的技巧和方法你了解多少?
  18. CMake使用总结(转的)+自己的实践心得
  19. json字符串与java对象的相互转换(jackson)
  20. git-定制属于你的log格式

热门文章

  1. JDK源码分析实战系列-PriorityQueue
  2. 图神经网络之预训练大模型结合:ERNIESage在链接预测任务应用
  3. 关于python实现html转word(docx)
  4. MySQL 常用到的几个字符处理函数
  5. python重要内置模块
  6. 个人电脑公网IPv6配置
  7. USB转TTL串口 (CH340 G)
  8. 如何使用 IdGen 生成 UID
  9. Python AI小项目打包通关:Pyinstaller和Wix都用上了
  10. 【世界杯黑技术专题】「原理探索专题」一文解读一下“卡塔尔世界杯”的先进技术之半自动越位技术SAOT+比赛用球Al Rihla