Use of multi-level pointers in C Language

Source: Internet
Author: User

Use of multi-level pointers in C Language

In a few words, the direct code below is a multi-level pointer, using the pointer variable to modify the value of the Variable

 

# Include

# Include


Void secondPoint (int *** a, float *** f, double ***** d, char ****** c ){
** A = 100;
* ** F = 9.2f;
* *** D = 3.14;
* *** C = 'G ';
}


Int main (){
Int a0 = 10;
Int * a = & a0;

Float f0 = 0.1f;
Float * f1 = & f0;
Float ** f2 = & f1;

Double d0;
Double * d1 = & d0;
Double ** d2 = & d1;
Double *** d3 = & d2;

Char c0;
Char * c1 = & c0;
Char ** c2 = & c1;
Char *** c3 = & c2;
Char ***** c4 = & c3;

SecondPoint (& a, & f2, & d3, & c4 );
Printf (a = % d, f = %. 1f, d = %. 2lf, c = % c, a0, f0, d0, c0 );

System (pause );
Return 0;

}

 

 

Note: pointer variables are used to store pointers of variables and cannot store values. For example:

Int * p = 10;

This method is invalid in C, because the pointer Variable p is the pointer of the stored variable and the constant value cannot be stored.

 



 

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.