Complete C language pointer Article 2

Source: Internet
Author: User

2. What is a pointer?

It's not easy to understand! Many of us who are new to pointer should feel this way. I often think about it. Why? In fact, there are pointers everywhere in life. We also use it everywhere. With it, our life is more convenient. No pointer makes life inconvenient. Believe it? See the following example.

This is an example of life: for example, if you want me to lend you a book, I went to your dormitory, but you are not in the dormitory, so I put the book on your shelf on the 2nd floor and 3rd, and put a piece of paper on your desk. The paper says: The book you want is on the shelf on the 3rd floor, 2nd. When you come back, you will see this note. You will know where I borrowed your book and put it. You can think about the function of this paper. It is not a book, and there is no book on it. So how do you know where the book is located? Because the book is written on the paper! In fact, this paper is a pointer. The content above is not the book itself, but the address of the book. You found the book I lent you through the pointer.

So what are the pointers in C and C ++? Continue with me. Let's see a statement that declares an integer pointer variable as follows:

Int * PI;

Pi is a pointer, of course we know, but in this case, you think pi must be something special. In fact, it is only a variable. There is no substantive difference from the variable mentioned in the previous article. Do not believe it.

Memory Address → 6 7 8 9 10 11 12 13 14

--------------------------------------------------------------

... | 30 | 'T' | ......

--------------------------------------------------------------

Variable | → I branch | → A branch | → PI branch |

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.