当前位置:网站首页>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)
边栏推荐
猜你喜欢

编程大杂烩(三)

Web Basics and Exercises for C1 Certification - My Study Notes

Tactile intelligent sharing - SSD20X realizes upgrade display progress bar

【问题解决】同一机器上Flask部署TensorRT报错记录

8. Custom mapping resultMap

idea设置识别.sql文件类型以及其他文件类型
![[C language advanced] program environment and preprocessing](/img/ac/a13dd2cc47136d4938b6fc7fad660c.png)
[C language advanced] program environment and preprocessing

Cannot read properties of null (reading 'insertBefore')

DP4398:国产兼容替代CS4398立体声24位/192kHz音频解码芯片

TensorRT例程解读之语义分割demo
随机推荐
C专家编程 第5章 对链接的思考 5.4 警惕Interpositioning
C语言 -- 操作符详解
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work
npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND
Performance testing with Loadrunner
MySql数据恢复方法个人总结
渗透测试(PenTest)基础指南
C Expert Programming Chapter 5 Thinking about Linking 5.2 Advantages of Dynamic Linking
[Cocos 3.5.2]开启模型合批
[Cocos] cc.sys.browserType可能的属性
7.13 Day20----MYSQL
力扣题解8/3
8.03 Day34---BaseMapper查询语句用法
BFC、IFC、GFC、FFC概念理解、布局规则、形成方法、用处浅析
day13--postman interface test
C Expert Programming Chapter 4 The Shocking Fact: Arrays and Pointers Are Not the Same 4.5 Other Differences Between Arrays and Pointers
Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
LCP 17. 速算机器人
腾讯136道高级岗面试题:多线程+算法+Redis+JVM
败给“MySQL”的第60天,我重振旗鼓,四面拿下蚂蚁金服offer