Pointer Memory Model 2: pointer Model
1 # define _ CRT_SECURE_NO_WARNINGS 2 # include <stdio. h> 3 # include <stdlib. h> 4 # include <string. h> 5 6 void print_Num (char myArray [10] [30], int num) 7 {8 int I = 0; 9 for (; I <num; I ++) 10 {11 printf ("% s", myArray [I]); 12} 13} 14 void sort_Num1 (char array [10] [30], int num) 15 {16 int I = 0, j = 0; 17 char mybuf [30]; 18 for (I = 0; I <num; I ++) 19 {20 for (j = I + 1; j <num; j ++) 21 {22 if (strcmp (array [I], array [j])> 0) 23 {24 strcpy (mybuf, array [j]); 25 strcpy (array [j], array [I]); 26 strcpy (array [I], mybuf ); 27} 28} 29} 30} 31 32 int main () 33 {34 int I = 0, j = 0; 35 int num = 5; 36 char mybuf [30]; 37 char array [10] [30] = {"aaaa", "dddd", "aac", "bbbb", "1121213"}; 38 39 // compiler only cares about: 10 rows, 30 columns, array + 1, 30 hops; 40/* int len1 = sizeof (array); 41 int len2 = sizeof (array [0]); 42 int num1 = len1/len2; 43 printf ("% d \ n", len1, len2, num1); */44 printf ("Before sorting: \ n "); 45 print_Num (array, num); 46 sort_Num1 (array, num); 47 printf (" sorted: \ n "); 48 print_Num (array, num); 49 50 system ("pause"); 51 return 0; 52}