Array: It is a sequence composed of data of the same type and is an ordered collection. (Its distribution in the memory is from low address to high address, and it is stored one by one, so it is an ordered set rather than the content inside it is ordered)
1. One-dimensional array definition:
类型说明符 数组名[常量表达式]
PS: The storage of one-dimensional arrays in memory. (Any program, including the operating system, must be loaded into the memory instead of running on the hard disk when it is running. It is impossible to run on the hard disk. The CPU adjusts data from the memory, and the memory fetches data from the hard disk. It’s a dynamic process, so you have to run something in the CPU and run it in the memory. Any program will be loaded into the memory as soon as it runs. So, for example, if you want to steal any password, you Should start from the memory, because the entire process of his compilation is running in memory)
Low address | 86 | mark[0] |
92 | mark[1] | |
77 | mark[2] | |
52 | mark[3] | |
... | ... | |
High address | 94 | mark[99] |
The array name is actually the first address of the first element of the array.
2. The general form of two-dimensional array definition is:
类型说明符 数组名 [常量表达式] [常量表达式]
The two-dimensional array is two-dimensional in concept, but the actual hardware memory is continuously addressed, that is to say, the memory cells are arranged in one-dimensional linear units. There are two ways to store a two-dimensional array in a one-dimensional memory: one is to arrange it in rows, that is, to put one row into the second row in sequence. The other is to arrange in columns, that is, put one column in the second column in sequence. In C language, two-dimensional arrays are arranged in rows.
The array must explain how much space it occupies at compile time (that is, the constant expression). Assignment is assigned at runtime.
Use the macro definition to comment out a sentence so that it does not execute:
#if(0)
语句1;//语句1永远不会被编译,因为if后边是0,为假跳过。
#endif
3. When the program is compiled and run, the ordinary variables are stored in the stack area, the stack area; while static will cause ordinary variables to be stored in the data area, that is, the data area. The data area generally cannot be changed, such as constants and strings. Generally in the data area.
PS: No matter what language you are, it is generally like this in memory. Our entire memory is mainly divided into four areas:
1): CODE (code area)
2): DATA (data area) (store constants, strings and variables defined with static) (the characteristics of the data area will not disappear because of the exit of this function) (the DATA area is when the entire program exits other Will be released)
3): STACK (stack area) (for any of our programs to run, he will push some data or some variables called by this function into the stack, and then run it, and then wait until the function is called. This stack will be released, otherwise your memory is far from enough)
4): HEAP area (Like the STACK area is released and generated by the program itself, while the HEAP area is different, the allocation size of the HEAP area is specified by the programmer, and you specify it as large as it is, of course, you cannot exceed its scope ,)
To understand these four partitions. . . . .