Second-level pointers are the first input model, and the first pointer model.
1 # define _ CRT_SECURE_NO_WARNINGS 2 # include <stdio. h> 3 # include <stdlib. h> 4 # include <string. h> 5 6 void printNum (char ** array, int num) 7 {8 int I = 0; 9 for (I = 0; I <num; I ++) 10 {11 printf ("% s", array [I]); 12} 13} 14 15 void sortNum (char ** array, int num) 16 {17 char * tmp = NULL; 18 int I = 0, j = 0; 19 for (I = 0; I <num; I ++) 20 {21 for (j = I; j <num; j ++) 22 {23 if (strcmp (array [I], array [j])> 0) 24 {25 tmp = array [I]; // note: the value of the exchanged data, the pointer is switched // the pointer is directed to 26 array [I] = array [j]; 27 array [j] = tmp; 28} 29} 30} 31} 32 33 int main () 34 {35 char * array [] = {"abbbb", "aaaa", "vvv ", "nnnn"}; 36 37 int num = 0; 38 char * tmp; 39 num = sizeof (array)/sizeof (array [0]); 40 printf ("Before sorting: "); 41 printNum (array, num); 42 sortNum (array, num); 43 printf (" sorted: "); 44 printNum (array, num ); 45 46 system ("pause"); 47 return 0; 48}