当前位置:网站首页>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)
边栏推荐
猜你喜欢
el-Select 选择器 底部固定
4.3 Annotation-based declarative transactions and XML-based declarative transactions
4.3 基于注解的声明式事务和基于XML的声明式事务
[One step in place] Jenkins installation, deployment, startup (complete tutorial)
Get the selected content of the radio box
word 公式编辑器 键入技巧 | 写数学作业必备速查表
8.03 Day34---BaseMapper query statement usage
FPGA学习笔记——知识点总结
Typora 使用保姆级教程 | 看这一篇就够了 | 历史版本已被禁用
MySQL数据库(基础)
随机推荐
MySQL date functions
《看见新力量》第四期免费下载!走进十五位科技创业者的精彩故事
Use Patroni callback script to bind VIP pit
4.3 Annotation-based declarative transactions and XML-based declarative transactions
4.1 声明式事务之JdbcTemplate
4.3 基于注解的声明式事务和基于XML的声明式事务
嵌入式系统驱动初级【3】——字符设备驱动基础中_IO模型
Gartner 权威预测未来4年网络安全的8大发展趋势
【问题解决】同一机器上Flask部署TensorRT报错记录
入坑软件测试的经验与建议
MySQL数据库面试题总结(2022最新版)
The Road to Ad Monetization for Uni-app Mini Program Apps: Full Screen Video Ads
What are the functions of mall App development?
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
【JS】js给对象动态添加、设置、删除属性名和属性值
符号表
C专家编程 第5章 对链接的思考 5.6 轻松一下---看看谁在说话:挑战Turning测验
MySQL log articles, binlog log of MySQL log, detailed explanation of binlog log
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
Uni-app 小程序 App 的广告变现之路:全屏视频广告