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.