Well, I have come to the fifth section without knowing it. In fact, we have already discussed C for more than half. As long as you have figured out the pointer concept, your C path has started, okay, let's continue to discuss pointers. Let's take a look at the definition of the pointer first. We define it as a variable and a variable used to record the address. How can we get a valid address? For example, if we have an integer val, can we use the & (Can we read it in English? How can we read the special symbols on the keyboard? How can we read it in English? What is this task, I handed it to the reader. If you don't know, you need to master this skill.) You can use this symbol to get the first address of val. Remember the concept of the first address. It's easy to understand. The obtained first address actually has a type, that is, the type of the variable, such
If val is of the char type, & val obtains the char * type. If val is of the integer type, & val obtains the int * type. In short, type val = x; & val: The obtained address is type *, and the pointer is the same. It means that if int * p = x; & p gets the address type of int **, I think it is not very difficult to understand.
In fact, these things will be prompted during compilation, as shown in
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/192FA5V-0.jpg "title =" 1.jpg" alt = "1331244.jpg"/>
So rest assured that the system will help us detect the address type. To eliminate this error, we can use forced type conversion, that is, adding (char *) Before & val *), type conversion. It's easy to understand...
Now we know how to get an address. What is the use of an address? The answer is certainly useful. This is about another operator, called the * operator. How can this operator be used? In fact, the usage is very simple. It is followed by an address. How can this problem be understood? Let's take a look at the following explanation:
* Address A: we have explained that there is A type of address, so this means that the number of bytes occupied by the type is retrieved from the start position of address A. Alas, when I typed, I felt that this sentence was quite difficult. I am not good at Chinese literature. Haha, you can endure it. I will give you a few examples and you will understand it ,, if address A is of the int * type and the value is 0X0012FF7C, we can use address A to obtain the value in address 0X0012FF7C-0X12FF7F. If address A is of the char * type, the value is 0X0012FF7C, so we can use * address A to retrieve the data of 0X0012FF7C, which is not difficult. So, when talking about the concept of type, as I said, it is very important to be gray. Because we will often use it later. Now let's discuss the issues that have been left behind. How can we determine whether a system is a small-end mode or a large-end mode? Do you feel very simple now?
# Include <stdio. h> int main () {int val = 1; char FirstByteVal = * (char *) & val; if (FirstByteVal = 1) printf ("small-end mode \ n "); else if (FirstByteVal = 0) printf ("big-end mode \ n"); else printf ("You have screwed me down \ n"); return 0 ;}
The purpose of this example is to take the first byte and determine whether it is 0 or 1. This is just a way to judge. There are still many methods. However, at work, the project manager usually does not care what method you use, but what he wants is the result, you must get the result, haha.
Remember the address followed by "*". If I give you an example, you can understand it, and you will understand it.
#include <stdio.h>int main(){ int val = 12; int * p = &val; int ** pp = &p; int *** ppp = &pp; printf("%d\n%d\n%d\n%d\n",val,*p,**pp,***ppp); return 0;}
What is the result of this Code? Why? You need to push the export process.
Let's take a look.
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/192F63V1-1.jpg "title =" 2.jpg" alt = "135544675.jpg"/>
Let's take a look at the four attributes of the table. The first row is
Variable Level 1 pointer Level 2 pointer Level 3 pointer
Then let's look at val's first address and p value, p's first address and pp value, pp's first address and ppp value, and we will find that they are the same and must be the same. The value of the pp we get from * ppp, and it is an int ** address. Once again, that is, ** ppp is equivalent to * (* ppp) = * (* 0X0012FF74) = * 0X0012FF78 = 0X0012FF7C. Do you understand it? I think you should understand it. It doesn't matter if you don't understand it. Read the first five articles several times, what did the Ancients say? I have read a book for tens of thousands of times. I have a deep understanding of its meaning. Have you read the first volume of TCP/IP? I have read it, I think it was a dizzy experience several times before, but later, the more easy it is to understand, the more you know what it is talking about, the more it is indeed like this. Believe me, it is absolutely true.
Well, now we all know what the pointer is, and you know the multi-level pointer. Does it feel useless? haha, it feels so normal. Because we don't know what a function is. What is the function? When we figure it out, we will discuss the usefulness of this pointer. In fact, we have mastered the theory very well. Many people who have been working for many years don't even understand what pointers are. Alas, I don't want to say anything anymore. Haha, you know.
Next, we will detail the stack. Very evil. Everyone must pay attention to the basic knowledge, because the basic is very important.
This article from the "Qian song" blog, please be sure to keep this source http://qianqianquege.blog.51cto.com/8004200/1304784