当前位置:网站首页>[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
边栏推荐
- SQL most commonly used basic operation syntax
- Cloud native - runtime environment
- [error prone points of C language] Part 4: detailed rules for storing structures in memory
- VS1003 debugging routine
- 03 pyechars rectangular coordinate system chart (example code + effect drawing)
- 企业数字化本质
- Ccf201912-2 recycling station site selection
- Application and download of dart 3D radiative transfer model
- 单调栈Monotonic Stack
- Phpstudy steps to quickly build a website (teach you to build it by hand)
猜你喜欢

2020-12-13

Interface control telerik UI for WPF - how to use radspreadsheet to record or comment

What if win11 cannot recognize Ethernet

2020-12-07

Fundamentals of machine learning - principal component analysis pca-16

黑猫带你学eMMC协议第24篇:eMMC的总线测试程序详解(CMD19 & CMD14)

黑猫带你学eMMC协议第26篇:eMMC的硬件复位操作(H/W reset)

Machine learning Basics - decision tree-12

机器学习基础-集成学习-13

Vs code is not in its original position after being updated
随机推荐
Leetcode206 reverse linked list
快速读入
Android工程师,如何使用Kotlin提供生产力?
Full disclosure! Huawei cloud distributed cloud native technology and Practice
SQL most commonly used basic operation syntax
LeetCode206 反转链表
线性分类器(CCF20200901)
归并排序
Solution to using json.tojsonstring to display question marks in Chinese in Servlet
云原生—运行时环境
Leetcode94. Middle order traversal of binary trees
[pictures and texts] detailed tutorial of one click reinstallation of win11 system
How can non-standard automation equipment enterprises do well in product quality management with the help of ERP system?
[July 5 event preview] Flink Summit
Remove the plug-in of category in WordPress link
【嵌入式C基础】第3篇:常量和变量
Rolling update strategy of deployment.
机器学习实战-决策树-22
Linear classifier (ccf20200901)
BiliBili Yang Zhou: above efficiency, efficient delivery