当前位置:网站首页>string类简介
string类简介
2022-08-04 05:16:00 【叽里呱啦呱】
简介: IOS/ANSI C++标准通过添加string类拓展了C++库,因此现在可以用string类型的变量(c++中称为对象)而不仅是字符数组来储存字符串,string类使用起来比数组简单,同时也提供了将字符串组作为一种数据类型的表示方式。
#要使用string类,必须要在程序中包含头文件string,string类位于命名空间std中。
使用string对象的方式与字符数组相同,但是类设计让程序可以自动处理string的大小,因此与数组相比string对象也更加安全
赋值,拼接,附值
可以像普通变量一样赋值,但是数组不能
string类简化了子字符串的合并操作可以使用运算符+将两个string对象合并起来,还可以用运算符+=将字符串附加到string对象的末尾
string类的其他操作
确定字符串的长度name.size(),c++string对象使用对象名和句点运算符来指出使用哪个字符串
输出均与字符数组一样,但整行输入有些区别,是这样表示的getline(cin,str)
其他形式的字符串字面值(有待补充)
边栏推荐
- [C language advanced] program environment and preprocessing
- DataTable使用Linq进行分组汇总,将Linq结果集转化为DataTable
- Turn: Management is the love of possibility, and managers must have the courage to break into the unknown
- el-Select 选择器 底部固定
- Large chain best freight d audit with what software?What are the functions?
- 路网编辑器技术预研
- [SemiDrive source code analysis] [MailBox inter-core communication] 47 - Analysis of RPMSG_IPCC_RPC mode limit size of single transmission and limit bandwidth test
- static在不同位置定义变量居然还有不同的含义?
- Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
- How to view sql execution plan offline collection
猜你喜欢

腾讯136道高级岗面试题:多线程+算法+Redis+JVM

7-2 LVS+DR Overview and Deployment

Turn: Management is the love of possibility, and managers must have the courage to break into the unknown

SLSA 框架与软件供应链安全防护

share总结

深度学习环境配置

读者让我总结一波 redis 面试题,现在肝出来了

数的划分之动态规划

关于yolo7和gpu
![[21 Days Learning Challenge] Image rotation problem (two-dimensional array)](/img/51/fb78f36c71e1eaac665ce9f1ce04ea.png)
[21 Days Learning Challenge] Image rotation problem (two-dimensional array)
随机推荐
System design. How to design a spike system (full version transfer)
How to keep the source code confidential in the development under the burning scenario
编程大杂烩(四)
[SemiDrive source code analysis] [MailBox inter-core communication] 47 - Analysis of RPMSG_IPCC_RPC mode limit size of single transmission and limit bandwidth test
2022年PMP考试延迟了,该喜该忧?
想低成本保障软件安全?5大安全任务值得考虑
C专家编程 第5章 对链接的思考 5.3 函数库链接的5个特殊秘密
leetcode 12. 整数转罗马数字
【流程图】
获取单选框选中内容
The Road to Ad Monetization for Uni-app Mini Program Apps: Full Screen Video Ads
What are the steps for how to develop a mall system APP?
震惊,99.9% 的同学没有真正理解字符串的不可变性
Teenage Achievement Hackers Need These Skills
Gartner 权威预测未来4年网络安全的8大发展趋势
There is an 8 hour difference between the docker installation of mysql and the host.
【21 Days Learning Challenge】Direct Insertion Sort
C Expert Programming Chapter 4 The Shocking Fact: Arrays and Pointers Are Not the Same 4.3 What is a Declaration and What is a Definition
Towards Real-Time Multi-Object Tracking (JDE)
转:管理是对可能性的热爱,管理者要有闯进未知的勇气