当前位置:网站首页>[embedded C foundation] Part 8: explanation of C language array
[embedded C foundation] Part 8: explanation of C language array
2022-07-28 13:02:00 【Black cat senior】
1 summary
Basic concept of array : A collection of data of the same type
1.1 Definition of array
Storage type data type Array name [ Element number ];
int a[5];
The number of elements must be constant , Can't be a variable
1.2 Initialization of an array
int a;
Array initialization method
All initialization :
int a[5] = {1, 2, 3, 4, 5};
Local initialization :
int a[5] = {1, 2, 3};
Be careful : Others are 0;
Commonly used :int arr[5] = {0}; // Initialize all elements as 0 Array of , Usually this method is used in clearing 0 Use... For arrays
Default initialization :
int a[] = {1, 2, 3, 4, 5};
int arr[] = {0}; // Less commonly used methods , This is equivalent to setting only 1 Array of elements , And the value of 0
Example :
int a[5] = {0}; // Yes , Local initialization , So all is 0 了
int a[] = {0}; // Yes , An element , Initialize to 0
int a[5] = {1, 2, 3, 4, 5}; // Yes
a = {1, 2, 3, 4, 5}; // wrong
Initialization is different from assignment
Initialization refers to the assignment of variable values by the system before the program runs , The assignment is completed after the program starts running , The assignment action belongs to program completion
int a; This is a variable definition without initialization
int a=1; This belongs to system initialization , The system applies for variables first a, And put this unit into the initial value 1
in
边栏推荐
- LeetCode每日一题(2196. Create Binary Tree From Descriptions)
- 【嵌入式C基础】第5篇:原码/反码/补码
- 【嵌入式C基础】第1篇:基本数据类型
- A brief introduction to the for loop. Some of the code involves arrays
- Flexpro software: measurement data analysis in production, research and development
- Machine learning practice - decision tree-22
- [graduation design] heart rate detection system based on single chip microcomputer - STM32 embedded Internet of things
- Qt 信号和槽机制( 详解 )
- 黑猫带你学eMMC协议第24篇:eMMC的总线测试程序详解(CMD19 & CMD14)
- VS1003 debugging routine
猜你喜欢

Quick read in

BiliBili Yang Zhou: above efficiency, efficient delivery

试用copilot过程中问题解决

Brother bird talks about cloud native security best practices

机器学习实战-神经网络-21

Remove the plug-in of category in WordPress link

LeetCode84 柱状图中最大的矩形

SQL most commonly used basic operation syntax

Ccf201912-2 recycling station site selection

Science heavyweight: AI design protein has made another breakthrough, and it can design specific functional proteins
随机推荐
BiliBili Yang Zhou: above efficiency, efficient delivery
Vs code is not in its original position after being updated
Leetcode94. Middle order traversal of binary trees
C# 泛型是什么、泛型缓存、泛型约束
Zurich Federal Institute of technology | reference based image super resolution with deformable attention transformer (eccv2022))
Black cat takes you to learn EMMC Protocol Part 24: detailed explanation of EMMC bus test program (cmd19 & cmd14)
Can molecular modeling solve the data dilemma of AI pharmacy?
区块反转(暑假每日一题 7)
企业数字化本质
Sliding Window
快速读入
Insufficient permission to pull server code through Jenkins and other precautions
Ruan Bonan of Green Alliance Technology: cloud native security from the open source shooting range
STM32 loopback structure receives and processes serial port data
LeetCode 42.接雨水
力扣315计算右侧小于当前元素的个数
Xampp Chinese tutorial guide
Databinding+LiveData轻松实现无重启换肤
Huawei cloud Gao Hongxia: CBC microservice code Reconstruction & independent release practice
Block reversal (summer vacation daily question 7)