Details of level 2 pointers in C Language

Source: Internet
Author: User

Details of level 2 pointers in C Language
Use the C language pointer as the function return value:

The C language allows the function to return a pointer (Address). We call such a function a pointer function.

After the function is executed, all local data defined in the function is destroyed.

# Include

# Include

Char * strlong (char * d, char * e ){

If (strlen (d)> strlen (e )){

Return d;

} Else {

Return e;

}

}

Int main (){

Char * a = "taoshihan ";

Char * B = "taoaaaaaaa ";

Char * c;

C = strlong (a, B );

Printf ("c = % s", c );

Return 0;

}

Second-level pointer of C language (pointer to pointer ):

A pointer can point to a common type of data, such as int, double, and char. It can also point to a pointer type of data, such as int *, double *, and char.

If a pointer points to another pointer, we call it a second-level pointer or a pointer to the pointer.

# Include

Int main (){

Int e = 100;

Int * B = & e;

Int ** c = & B;

Printf ("% d, % d, % d \ n", e, * B, ** c );

Printf ("& e = % # x, B = % # x, & B = % # x, c = % # x \ n", & e, B, & B, c );

Return 0;

}

& E = 0xbfe7c530, B = 0xbfe7c530, & B = 0xbfe7c534, c = 0xbfe7c534

The address of e is 0xbfe7c530, B is the pointer address is 0xbfe7c530, and B points to e.

The address of the B pointer variable itself is 0xbfe7c534, and the address of the c pointer is 0xbfe7c534.

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.