当前位置:网站首页>The string class introduction
The string class introduction
2022-08-04 05:35:00 【quack quack】
Introduction: The IOS/ANSI C++ standard extends the C++ library by adding the string class, so you can now use string-type variables (called objects in C++)Rather than just storing strings as character arrays, the string class is simpler to use than arrays, and also provides a way to represent groups of strings as a data type.
#To use the string class, the header file string must be included in the program, and the string class is located in the namespace std.
Use string objects in the same way as character arrays, but the class design allows the program to automatically handle the size of the string, so string objects are also safer than arrays
Assignment, splicing, adding value
You can assign values like normal variables, but arrays cannot
The string class simplifies merging of substrings. You can use the operator + to combine two string objects, and you can use the operator += to append strings toend of string object
Other operations of the string class
Determine the length of the string name.size(), the c++ string object uses the object name and the period operator to indicate which string to use
The output is the same as the character array, but the input of the whole line is somewhat different, which is expressed as getline(cin,str)
Other forms of string literals (to be added)
边栏推荐
- word 公式编辑器 键入技巧 | 写数学作业必备速查表
- 力扣:746. 使用最小花费爬楼梯
- FPGA学习笔记——知识点总结
- 【云原生--Kubernetes】Pod资源管理与探针检测
- 触觉智能分享-SSD20X实现升级显示进度条
- 力扣:63. 不同路径 II
- Write golang simple C2 remote control based on gRPC
- [Evaluation model] Topsis method (pros and cons distance method)
- 自动化测试的成本高效果差,那么自动化测试的意义在哪呢?
- JS basics - forced type conversion (error-prone, self-use)
猜你喜欢
随机推荐
C专家编程 第5章 对链接的思考 5.3 函数库链接的5个特殊秘密
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
[Cocos] cc.sys.browserType可能的属性
处理List<Map<String, String>>类型
MySQL数据库面试题总结(2022最新版)
败给“MySQL”的第60天,我重振旗鼓,四面拿下蚂蚁金服offer
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
Grain Mall - Basics (Project Introduction & Project Construction)
C专家编程 第5章 对链接的思考 5.4 警惕Interpositioning
在被面试官说了无数次后,终于潜下心来整理了一下JVM的类加载器
Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
Interesting Kotlin 0x0E: DeepRecursiveFunction
About yolo7 and gpu
JS基础--强制类型转换(易错点,自用)
代码重构:面向单元测试
力扣:746. 使用最小花费爬楼梯
渗透测试(PenTest)基础指南
MySql data recovery method personal summary
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
static在不同位置定义变量居然还有不同的含义?