How to understand the pointers in C language

Source: Internet
Author: User

Recently have learned C language in the pointer knowledge, the head is big, vaguely understand half, by himself checked the next information, with you to share the C language pointers in the basic knowledge of it:

1, the pointer is an address, pointing to a type.

2: The pointer points to the address, and the address points to the content.

We need a variable to store the address, the value of this variable is the address, but we can change the value of the variable constantly, but if we need to change the value of that address, we need to modify the value of the address without changing the address.

int a = 10;

int *p;

p = &a;

*p = 11;

A=?

Here we see that p is a variable, we use P to store the address of the variable A, which is, we use *P to assign a value to this variable, then the value of a is finally, how much, the result is 11, because we use the *p assignment, is equivalent to a=11, the same assignment effect.

3: Pointer is a pointer to a variable that is facing the pointer.

We say that when pointers are pointers, it's a bit unclear how to differentiate pointers and pointers.

Char *p;

Char **PR;

PR = &p;

We see it this way, char * (*PR); *PR is a variable that stores values as pointers, and PR is the variable that stores the address of the previous variable. In combination, a PR is a variable that stores the address of a value as a pointer.

How to understand the pointers in C language

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.