当前位置:网站首页>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 .
边栏推荐
- Why some people earn nearly 10billion a year, while others earn 3000 a month: the details you ignore actually make the most money
- 【R语言】两个/N个数据合并merge函数
- [R language] age sex frequency matching select samples for case-control study, and perform frequency matching on age and sex
- Wang Yingqi, founder of ones, talks to fortune (Chinese version): is there any excellent software in China?
- Kickback -- find the first palindrome character in a group of characters
- MATLAB之基础知识
- 软件测试方法和技术 - 基础知识概括
- Stepsister becomes stepmother, son breaks off relationship with himself, and musk, the world's richest man, why is it so miserable?
- Basic knowledge of MATLAB
- [recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario
猜你喜欢

Why some people earn nearly 10billion a year, while others earn 3000 a month: the details you ignore actually make the most money

JAX的深度学习和科学计算

Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)
![[programming compulsory training 3] find the longest consecutive number string in the string + the number that appears more than half of the times in the array](/img/5e/068268857b8c7c2065ba552fd23dbb.png)
[programming compulsory training 3] find the longest consecutive number string in the string + the number that appears more than half of the times in the array

2022 electrician (intermediate) recurrent training question bank and answers

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

Redisson uses the full solution - redisson official document + comments (Part 2)

2022年流动式起重机司机考试练习题及在线模拟考试

How to make the two financial transactions faster

Inftnews | from "avalanche" to Baidu "xirang", 16 major events of the meta universe in 30 years
随机推荐
[programming compulsory training 3] find the longest consecutive number string in the string + the number that appears more than half of the times in the array
组件的自定义事件①
How relational databases work
JAX的深度学习和科学计算
[Shenzhen IO] precise Food Scale (some understanding of assembly language)
下载Xshell和Xftp
【目标检测】目标检测界的扛把子YOLOv5(原理详解+修炼指南)
浅谈CVPR2022的几个研究热点
[programming training] delete public characters (hash mapping) + team competition (greedy)
C# Newtonsoft.Json中JObject的使用
力扣——求一组字符中的第一个回文字符
Huawei modelarts training alexnet model
go通用动态重试机制解决方案的实现与封装
redisson使用全解——redisson官方文檔+注釋(上篇)
1286_ Implementation analysis of task priority setting in FreeRTOS
Do securities account opening affect the security of account opening
长路漫漫、技术作伴
关系数据库如何工作
Autosar 学习记录(1) – EcuM_Init
base64