Understanding and understanding of pointers

Source: Internet
Author: User

Understanding and understanding of pointers

Int main (void)

{

Int;

Int * p; int ** p1; a = 5; p = & a; p1 = & p; printf ("\ n "); printf ("the address of a is % p \ n", & a); printf ("the value of p is % p and the adress of p is % p \ n ", p, & p); printf ("the value of p1 is % p and the address of p1 is % p \ n", p1, & p1 ); printf ("\ n"); printf ("a's value is % d \ n", ); printf ("a's value is % d access by first pointer \ n", * p); printf ("a's value is % d access by second pointer \ n ", * (* p1); printf ("\ n ");}
The output result is as follows:
The address of a is invalid value of p is 0x7fffd57a181c and the adress of p is invalid value of p1 is 0x7fffd57a1808 and the address of p1 is 0x7fffd57a1810 a's value is 5a's value is 5 access by first pointera's value is 5 access by second pointer

Resolution:
P = &;
P = address of variable a = 0x7fffd57a181c
* P = value of a = 5 // Level 1 pointer

P1 = & p;
P1 = address of Variable p
* P1 = value of Variable p = address of variable
* (* P1) = * (value of Variable p) = * (address of variable a) = 5

Related Article

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.