当前位置:网站首页>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)
边栏推荐
- 【一步到位】Jenkins的安装、部署、启动(完整教程)
- The difference between px, em, and rem
- Can‘t connect to MySQL server on ‘localhost3306‘ (10061) 简洁明了的解决方法
- 心余力绌:企业面临的软件供应链安全困境
- Use Patroni callback script to bind VIP pit
- npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa
- As soon as flink cdc is started, the CPU of the source Oracle server soars to more than 80%. What is the reason?
- 力扣:509. 斐波那契数
- Canal mysql data synchronization
- Cannot read properties of null (reading 'insertBefore')
猜你喜欢
随机推荐
Towards Real-Time Multi-Object Tracking (JDE)
8大软件供应链攻击事件概述
编程大杂烩(三)
8、自定义映射resultMap
Resolved error: npm WARN config global `--global`, `--local` are deprecated
文献管理工具 | Zotero
string类简介
LCP 17. 速算机器人
Gartner 权威预测未来4年网络安全的8大发展趋势
npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND
What are the functions of mall App development?
嵌入式系统驱动初级【4】——字符设备驱动基础下_并发控制
canal实现mysql数据同步
What are the steps for how to develop a mall system APP?
4.1 声明式事务之JdbcTemplate
npm init [email protected] 构建项目报错SyntaxError: Unexpected token ‘.‘解决办法
应届生软件测试薪资大概多少?
9、动态SQL
代码重构:面向单元测试
JS基础--强制类型转换(易错点,自用)