当前位置:网站首页>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)
边栏推荐
猜你喜欢
随机推荐
嵌入式系统驱动初级【3】——字符设备驱动基础中_IO模型
解决错误:npm WARN config global `--global`, `--local` are deprecated
8. Custom mapping resultMap
心余力绌:企业面临的软件供应链安全困境
What are the functions of mall App development?
Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
动态规划总括
npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND
4.3 基于注解的声明式事务和基于XML的声明式事务
C Expert Programming Chapter 5 Thinking about Linking 5.2 Advantages of Dynamic Linking
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.3 什么是声明,什么是定义
处理List<Map<String, String>>类型
C Expert Programming Chapter 5 Thinking about Linking 5.3 5 Special Secrets of Library Linking
Grain Mall - Basics (Project Introduction & Project Construction)
MySQL数据库面试题总结(2022最新版)
4.1 声明式事务之JdbcTemplate
力扣:509. 斐波那契数
编程大杂烩(三)
word 公式编辑器 键入技巧 | 写数学作业必备速查表
力扣:96.不同的二叉搜索树