当前位置:网站首页>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)
边栏推荐
- npm init [email protected] 构建项目报错SyntaxError: Unexpected token ‘.‘解决办法
- [One step in place] Jenkins installation, deployment, startup (complete tutorial)
- Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
- Dynamic programming of the division of numbers
- 《看见新力量》第四期免费下载!走进十五位科技创业者的精彩故事
- C Expert Programming Chapter 5 Thinking about Linking 5.2 Advantages of Dynamic Linking
- 7、特殊SQL的执行
- 12. Paging plugin
- LCP 17. 速算机器人
- Can‘t connect to MySQL server on ‘localhost3306‘ (10061) 简洁明了的解决方法
猜你喜欢

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

Shocked, 99.9% of the students didn't really understand the immutability of strings

部署LVS-DR群集【实验】

What is the salary of a software testing student?

企业需要知道的5个 IAM 最佳实践

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

The idea setting recognizes the .sql file type and other file types

编程大杂烩(三)

心余力绌:企业面临的软件供应链安全困境

Performance testing with Loadrunner
随机推荐
力扣:509. 斐波那契数
C Expert Programming Chapter 5 Thinking about Linking 5.2 Advantages of Dynamic Linking
TSF微服务治理实战系列(一)——治理蓝图
[Evaluation model] Topsis method (pros and cons distance method)
MySQL date functions
一个对象引用的思考
What is the salary of a software testing student?
力扣:62.不同路径
JS basics - forced type conversion (error-prone, self-use)
The symbol table
C专家编程 第5章 对链接的思考 5.2 动态链接的优点
[SemiDrive source code analysis] [MailBox inter-core communication] 47 - Analysis of RPMSG_IPCC_RPC mode limit size of single transmission and limit bandwidth test
少年成就黑客,需要这些技能
解决错误:npm WARN config global `--global`, `--local` are deprecated
字节最爱问的智力题,你会几道?
使用Loadrunner进行性能测试
Web Basics and Exercises for C1 Certification - My Study Notes
BFC、IFC、GFC、FFC概念理解、布局规则、形成方法、用处浅析
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
sql server如何得到本条记录与上一条记录的差异,即变动值