当前位置:网站首页>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)
其他形式的字符串字面值(有待补充)
边栏推荐
- DataTable uses Linq for grouping and summarization, and converts the Linq result set into DataTable
- Will the 2023 PMP exam use the new version of the textbook?Reply is here!
- Hangdian Multi-School-Slipper- (tree map conversion + virtual point mapping)
- go module的介绍与应用
- 3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.3 什么是声明,什么是定义
- 转:管理是对可能性的热爱,管理者要有闯进未知的勇气
- Interesting Kotlin 0x0E: DeepRecursiveFunction
- 8款最佳实践,保护你的 IaC 安全!
- [Cocos] cc.sys.browserType可能的属性
猜你喜欢

Do you think border-radius is just rounded corners?【Various angles】

Structure function exercise

docker安装mysql与宿主机相差8小时的问题。

7-3 LVS+Keepalived Cluster Description and Deployment

震惊,99.9% 的同学没有真正理解字符串的不可变性

TSF微服务治理实战系列(一)——治理蓝图

【评价类模型】Topsis法(优劣解距离法)

idea设置识别.sql文件类型以及其他文件类型

How to keep the source code confidential in the development under the burning scenario
![[One step in place] Jenkins installation, deployment, startup (complete tutorial)](/img/f2/15fb546eb864d7ff40b5507d5c7aa5.png)
[One step in place] Jenkins installation, deployment, startup (complete tutorial)
随机推荐
[Cocos 3.5.2]开启模型合批
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.4 Matching declarations to definitions
[Evaluation model] Topsis method (pros and cons distance method)
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
Hangdian Multi-School-Slipper- (tree map conversion + virtual point mapping)
Plus版SBOM:流水线物料清单PBOM
详解八大排序
The 2022 PMP exam has been delayed, should we be happy or worried?
System design. Seckill system
商城系统APP如何开发 都有哪些步骤
Redis common interview questions
Jenkins export and import Job Pipeline
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.5 数组和指针的其他区别
力扣:96.不同的二叉搜索树
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.2 我的代码为什么无法运行
FPGA学习笔记——知识点总结
leetcode 12. Integer to Roman numeral
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.3 什么是声明,什么是定义
附加:对于“与数据表对应的实体类“,【面对MongoDB时,使用的@Id等注解】和【以前面对MySQL时,使用的@Id等注解】,是不同的;
如何打造一篇优秀的简历