On that basic problem of pointer

1。 Assign a variable and memory space will be allocated to this variable. The address of a space is like a room number. You can find the address according to the number, but the space allocated to you is not NULL after p=NULL, but sizeof(p)! In other words, it is not that your space size is NULL, but that what you put in your space is "NULL", and your space size is a problem of sizeof.

2。 First of all, what you wrote is wrong. Judging equality should be a double equal sign = =, not =, that is to say, it is p==NULL, not p=NULL, and p=NULL is an assignment, not a judgment. It is to assign a NULL value to p, not to judge whether p is NULL. And p==NULL, this is not to judge whether the space has a size, but to judge whether the things stored in this room are NULL, that is, whether the value of p is null-as I said in the answer to the first question, the size of the space is one thing, and so are the things put in the space.

3。 From the above, you should see that the statement that *q has a size is wrong. It's not that "*q" has a size, but that this place has a specific value. Presumably, when you say size, you mean that *q has been handed in. But I have one more question for you. Is the assignment statement you see "q=" or "*q="? You know, it's far from the asterisk! Q= indicates that the address Q has been specified, which is equivalent to the key to the specified room being placed in this room. And *q= indicates what is in the room pointed by this key! The key you got is different from what you put in the room.

So I will continue to ask the following questions: Are you sure you saw p=q, not *p=*q, not *p=q, and not p=*q? If you say that it is indeed p = q, it will be easy, that is to say, your room key Q has been copied, that is, P. These two keys can open the same room. However, your statement is wrong, that is, the value of p is equal to the value of q, and the address is their value. Instead of the address of P equals the address of Q, or that sentence, the address is equivalent to the key, and the things at home are called values. Here, P and Q are pointers, and their values are what is in their room. This thing, because they are addresses, is also a key, pointing to another room. Their address is their own key.

4。 When p=q, then *p and *q are naturally a value, which is equivalent to two keys in a room. Naturally, *q (equivalent to things in room Q) and * P (things in room P), isn't this different? P and q share the same room).

In a word: type * pointer name (such as int *p), this statement is to declare a pointer to the "type" address, which has its own address, that is, its own room, but the things in his room are signposts and keys pointing to a certain room of the declared type.