Programmer account notes (9)

xiaoxiao2021-03-06  97

Today, I finally arrived in the core part of the C language. The pointer has always been a big focus of learning C language. If we don't learn a C language pointer, then we can say that there is no C language. . But then, when I first started to contact C, the basic syntax of the front is very fast, but I learned that the pointer is stupid in the array. Because I don't know why there are so many array calls. (Binding to the pointer). In fact, I'm very difficult to understand the guy. Please ask you to debug a lot of debugging. After adding the experience, look back and look at the chapter of the pointer, I believe it can also touch it. Because I also came over, I also read a lot of source program using pointers. Now we start with a relatively simple one-dimensional array relative to the two-dimensional array, first look at how to define a pointer to the one-dimensional array. INT A [5] = {1, 2, 3, 4, 5}; int * p; p = a; / * Here A is because it is a group of variable names, its value is the first address of this array * / follow us You can change the value of the array of value P ; * p = 6; / * The second element of the array is equal to 6 * / The meaning here is to move the pointer down, and point to the second part of the array. Element. Let's take a look at its address, through this pointer, the address of the current pointing element. Then how the address is running? The P this command is to move down. If you follow the type of array A, the array A is an integer, the space is two bytes, and the p is only 1, and the top is to the first In the last half of an element, can you point to the second element? In fact, here is the type when defining a pointer, we define the integer type here, "Yes, define the integer is right, because it wants to point to plastic data, then of course, it is necessary to define this type. "", In fact, this is not a real answer, and it is not necessary to define as the same type as the point to point, and we can define the type of pointer to other. For example, it is defined as float, but here is executing P directly skip a array element, then let's take a look at what is going on. In fact, our defined pointer type is used to combine a pointer to make a certain rules. Here, it can be seen that if it is the definition int type, you can go to the second element, indicating that P is not a simple address plus one, but first combines this type to make an operation, add once, equal to the address. 2. The Float moved 4 digits, so the combination obtained was moved to the third element.

Take a look at: a = a 1; here we perform address shift assignment, but this command is wrong, the C language is a set of address constants, so it does not change its value. Next, it is said that the two-dimensional array is, because our task today is to first figure out a one-dimensional number of groups first. Now let's define a two-dimensional array Int a [2] [4]; here I don't repeat things in the book, I tell the idea of ​​the teacher gives us. Let's take a look at a two-dimensional array, which is a one-dimensional array of elements, so nested. Of course, the other multi-dimensional numbers are nestled in this way. Let's take a look at this picture as shown in the ninth day.

转载请注明原文地址:https://www.9cbs.com/read-124130.html

New Post(0)