#include Void Pop (int (* ptr) [4]); // Function prototype, define an int type containing 4 elements of pointer array void POP2 (int (* ptr) [4], int n); // Function prototype, define an Int type of pointer array, and an int main (void) {Int Multi [3] [4] = {1, 2, 3, 4} {5, 6, 7, 8}, {9, 10, 11, 12}; int (* ptr) [4], count; PTR = MULTI; // 2 times, sequentially print out two-dimensional array Each element, because it is not recycled 2 times, only 1, 2, 3, 4, followed by the 5, 6, 7, 8, and 9, 10, 11, 12 POP (PTR ); // Some function calls are direct POP (); in this example, it is wrong. Remember, if the function is not passed to the function when defined the function, it should be void puts ("/ n ------------------------------------------------------------------------------------------ --- "); getchar (); // Press the number of display results of the second method of printing POP2 (MULTI, 3); GetCh ();
Void Pop (int * p, count; p = (int *) PTR; / / Forced to convert to int type // 3 times, print each element of two-dimensional array For (count = 0; count <4; count ) Printf ("/ n% d", * p ); / / pointer is the address assignment to the address, and must be added when printing, otherwise printing out The geology rather than data}
// Second method VOID POP2 (int (* ptr) [4], int N) {int * p, count; p = (int *) PTR; / / forced to convert to int type // 11 times for ( Count = 0; Count <(4 * n); count ) Printf ("/ n% d", * p );}