Tag:c memory model level two pointer
Second memory model for #include <stdio.h> #include <stdlib.h> #include <string.h>/* two-level pointers */// Print string array Int printarray (char arraystr[10][30],int num) { int i = 0; for (i=0; i<num; i++) { printf ("%s \n", Arraystr[i]); } return 0;} Sort Int sortarraystr (char arraystr[10][30],int num) { int i = 0, j = 0; char buf[20]; for (i=0; i<num; i++) { for (j=i+1; j<num; j++) { if (strcmp (arraystr[i],arraystr[j]) > 0) { strcpy (Buf,arraystr[i]); strcpy (Arraystr[i],arraystr[j]); strcpy (ARRAYSTR[J],BUF); } } } return 0;} Secondary pointer second memory model Int main () { char arraystr[10][30] = {"CCCC", "AAAA", " BBBBB "," 11111 "}; printf (" before ordering \ n "); printarray (arrayStr,4); sortarraystr (arraystr,4); printf ("after ordering \ n"); PrintArray (arraystr,4); system ("pause"); return 0;}
C Two-level pointer memory model two