当前位置:网站首页>About char str[20]= "" and char str[20]=““
About char str[20]= "" and char str[20]=““
2022-07-21 23:31:00 【Chinese a man】
As the title , Define a length of 20 String , The difference is that there is nothing in a double quotation mark , There is a space in the other double quotation mark . In order to know what the string stored in the array is , We use the debugging function , see str What is in the array .
This is a str[20]=""
This is a str[20]=" "
So that we can know , When we drive 20 Byte character array , And when there are not enough characters , It will automatically add '\0', So we can see , One only repeats 19 Time , One only repeats 18 Time , that '\000' What is it ?
According to the Internet :\000 yes \0 Three digit octal
Let's do another example , We can use double quotation marks as an array of spaces , The second element is changed to e , At this time, the number of repetitions is determined by 18 Turned into 17, And the final output , It's exactly what we want (puts The output defaults to one line , no need \n)
The same way , We use it on arrays that have nothing in double quotes , Find that the situation is not the result we expected
What's the reason for this ?
The possible reason is , According to what we just said ,\000, May be \0 The effect of , When we change the second element , The first is still \000, So the string is equivalent to the end , The final output is naturally a blank
When we modify the first element , It turned out that it was modified
When we modify both the first and the second , Find out , The output is as we expected
summary :str[20]="" and str[20]=" ", In fact, there is no big difference , It's usually out of the same imagination as a number array , Initialize the array to 0, Then use circulation and other means , Modify its value . Since its size was defined at the beginning as 20, When the total bytes modified later are insufficient 20 When , The remaining bytes ( It's not used ) No output , This is its advantage .
边栏推荐
- 2021 MCU WiFi competition new pattern, domestic MCU WiFi chip inventory, appendix 2020/2021 MCU WiFi ranking
- 测试用例管理工具推荐
- [advanced semiconductor process technology series] strained silicon process technology
- Analysis of matter protocol characteristics (III) device discovery, authentication and distribution network
- Is the subscript operator a monocular operator or a binocular operator
- MGRE experiment
- 电气EPlan软件第六章到第十章的学习
- 软件测试49个必问面试题合集+答案
- 用指针实现数组的排序
- 你是怎么理解自动化测试的?理解自动化测试的目的和本质
猜你喜欢
A brief summary of the programming journey in recent years···
Flexible use of postman tools
Watermelon book chapter 3 - linear model
rip综合实验
拼夕夕面试题之优惠券超发怎么去测试?
Understanding of timer bidirectional break inputs based on stm32h7x3 series
Database beginner's notes
CocosCreator 3. X environment construction
Wifi6 features, in-depth study together, OFDMA, QAM modulation, BSS
电气EPlan软件第六章到第十章的学习
随机推荐
JS Basics
OSPF experiment
Summary of common methods of string
MGRE---OSPF 实验
STM32 series timer complementary output details
一句话需求怎么测
Visualstudio2019 configuring point cloud library pcl1.11.1+ Stanford rabbit test
List set map queue deque stack traversal method summary
数据分析入门的经典书籍——《精益数据分析》
Hololens reading and downloading JSON files (personal hololens2 advanced development summary II)
005_ SS_ Palette Image-to-Image Diffusion Models
MGRE experiment based on OSPF
Data visualization application installation and deployment | common problems tutorial using datart installation package and source code deployment
Watermelon book chapter 3 - linear model
Three kinds of interval coverage problems based on greed
拼夕夕面試題之優惠券超發怎麼去測試?
rip綜合實驗
How can enterprises do well in data management? How to select products?
MySQL delete a large number of data tables are locked, and the thread is in the killed state after killing the thread. The problem is solved
回归测试怎么做