Countless textbooks have hardly taken this seriously. Is the array name a pointer to the first element of the array? Guess the following Code What is the output: Char Ga [] = " Abcdefghijklm " ;
Void My_array_func ( Char Ca [ 10 ]) {
Printf ( " Address of array Param = % # x \ n " , & CA );
Printf ( " Address of Ca [0] = % # x \ n " , & Ca [ 0 ]);
Printf ( " Address of Ca [1] = % # x \ n " , & Ca [ 1 ]);
Printf ( " ++ Ca =%# x \ n " , ++ CA );
}
Void My_pointer_func ( Char * Pa) {
Printf ( " Address of PTR Param = % # x \ n " , & Pa );
Printf ( " Address of PA [0] = % # x \ n " , & Pa [ 0 ]);
Printf ( " Address of PA [1] = % # x \ n " , & Pa [ 1 ]);
Printf ( " ++ PA =%# x \ n " , ++ Pa );
}
Int Main ()
{
Printf ( " Address of Global Array = % # x \ n " , & Ga );
Printf ( " Address of Ga [0] = % # x \ n " , & Ga [ 0 ]);
Printf ( " Address of Ga [1] = % # x \ n " , & Ga [ 1 ]);
My_array_func (GA );
My_pointer_func (GA );
System ( " Pause " );
Return 0 ;
}
If you find that the address of the first element of the result array parameter is different from that of the array parameter, please print it in two my_func.* (& Ca)And* (& PA). If you use sizeof to check the size of the parameter array at this time, you will be more surprised. Try it yourself ;-)