Experiment description of C language pointer

Source: Internet
Author: User

<Div align = "left"> <pre class = "cpp" name = "code"> when I went to compile principles in the morning, I heard about the C language pointer, some questions, so I went back to the dormitory for lab verification.

<P> when a function parameter is a pointer, when this function is called, does the form parameter of this function obtain the pointer itself or a copy of it? The following code: </p> <p> # include "stdio. h"
 
Void change1 (int * d)
{
Printf ("address_d = % d * d = % d \ n", & d, d, * d );
Int s = 4;
D = & s;
Printf ("address_d = % d * d = % d \ n", & d, d, * d );
}
 
Void change2 (int * e)
{
* E = 5;
}
 
Int main ()
{
Int * p (NULL );
Int * q (NULL );
Int a (1 );
While ()
{
Scanf ("% d", & );
Printf ("address_a = % d a = % d \ n", & a, );
P = &;
Q = p;
Printf ("address_P = % d p = % d * p = % d \ n", & p, p, * p );
Printf ("address_q = % d q = % d * q = % d \ n", & q, q, * q );
Change1 (q );
Printf ("address_q = % d q = % d * q = % d \ n", & q, q, * q );
Change2 (q );
Printf ("address_a = % d a = % d \ n", & a, );
Printf ("address_q = % d q = % d * q = % d \ n", & q, q, * q );
Printf ("address_P = % d p = % d * p = % d \ n", & p, p, * p );
}
}
</P>

Author: wche1990

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.