当前位置:网站首页>Two expressions of string
Two expressions of string
2022-07-01 07:47:00 【On the bald Road】
1.c++ Inherited c Writing , character string c The style of writing :
char b[4] = { 'w','c','c','\0'};
char a[6] = { "loveu" };
/*char a[6] = { "loveuy" }; By default, it will be followed by /0 To indicate the end , So it's better than 6 One less bit to store /0, This writing will report an error */
2.C++ Their own string type
string s = "run";
example :
#include<iostream>
using namespace std;
int main() {
// character string c The style of writing
char b[4] = { 'w','c','c','\0'};
char a[6] = { "loveu" };
/*char a[6] = { "loveuy" }; By default, it will be followed by /0 To indicate the end , So it's better than 6 One less bit to store /0, This writing will report an error */
cout << a <<endl;
cout << b << endl;
// character string c++ Style writing
string s = "run";
cout << s << endl;
// String common functions
// Connect
string s1 = "run";
string s2 = "go";
string str = s1 + s2;
cout << str << endl;
// Copy
string s3;
s3 = s2;
cout << s3;
// Return string s1 The length of .
return 0;
}Add : Connection copy function of string (strcpy,strcat) Can't use , Personal access to data is considered abandoned by the version , The available methods are given in the code .
边栏推荐
- 热烈祝贺五行和合酒成功挂牌
- Long way to go with technology
- redisson使用全解——redisson官方文档+注释(中篇)
- kubernetes资源对象介绍及常用命令(二)
- [MySQL learning notes27] stored procedure
- Stepsister becomes stepmother, son breaks off relationship with himself, and musk, the world's richest man, why is it so miserable?
- [skill] create Bat quick open web page
- 【无标题】
- How relational databases work
- Inftnews | from "avalanche" to Baidu "xirang", 16 major events of the meta universe in 30 years
猜你喜欢

2022 electrician (intermediate) recurrent training question bank and answers

How to make the two financial transactions faster

Alibaba OSS postman invalid according to policy: policy condition failed: ["starts with", "key", "test/"]

软件测试方法和技术 - 基础知识概括

redisson使用全解——redisson官方文檔+注釋(上篇)

Array: question brushing record

ONES 创始人王颖奇对话《财富》(中文版):中国有没有优秀的软件?

【批处理DOS-CMD命令-汇总和小结】-Cmd窗口中常用操作符(<、<<、&<、>、>>、&>、&、&&、||、|、()、;、@)
![[target detection] yolov5, the shoulder of target detection (detailed principle + Training Guide)](/img/47/80d2e92ea7347cc5c7410194d5bf2e.png)
[target detection] yolov5, the shoulder of target detection (detailed principle + Training Guide)

组件的自定义事件①
随机推荐
redisson使用全解——redisson官方文档+注释(中篇)
Saving db4i depth camera pictures with MATLAB
Will Internet talents be scarce in the future? Which technology directions are popular?
Gru of RNN
redisson使用全解——redisson官方文档+注释(下篇)
The H5 page has set the font thickness style, but the wechat access style in Huawei mobile phone doesn't take effect?
PWN攻防世界int_overflow
The triode is a great invention
[MySQL learning notes 26] view
Atguigu---- scaffold --02- use scaffold (2)
TCP/UDP 通信问题整理
Alibaba OSS postman invalid according to policy: policy condition failed: ["starts with", "key", "test/"]
力扣——求一组字符中的第一个回文字符
[recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario
AUTOSAR learning record (1) – ECUM_ Init
继妹变继母,儿子与自己断绝关系,世界首富马斯克,为何这么惨?
熱烈祝賀五行和合酒成功掛牌
vscode 根据 ESLint 规范自动格式化代码
[chapter 72 of the flutter problem series] a solution to the problem that pictures taken in the flutter using the camera plug-in are stretched
go通用动态重试机制解决方案的实现与封装