#include <stdio.h>//void Show (char *p[]);voidShowChars[][Ten]);intMain () {Chars[3][Ten]={"123","ABC","XYZ"}; Char*p[Ten]; //array of pointers to iterate overp[1] = s[1]; Char(*PS) []; PS=s;}
#include <stdio.h>#include<string.h>#defineSIZE 80#defineLMT 3#defineHALT ""/** * String sort function function prototype declaration*///if a two-dimensional array is passed directly, only the array elements can be displayed inside the function, and the element position cannot be changedvoidStr_sort (CharStr[][size],intnum);//void Str_sort (char *str,int num);intMain () {CharInput[lmt][size]; //array of pointers, to assign values to each element individually, pointers to multidimensional arrays only need to assign values to pointer variables//to specify the size of the array when the pointer array is initialized, a pointer to a multidimensional array allocates only the memory space of the pointer variable Char*PS[LMT]; intCT =0; intK; while(CT<LMT && gets (input[ct])! = NULL && input[ct][0] !=' /') {PS[CT]=INPUT[CT]; CT++; } //Str_sort (PS,CT);Str_sort (INPUT,CT); //puts ("Here is the Res list:"); //For (k=0;k<ct;k++) {//puts (ps[k]); //} return 0;}voidStr_sort (CharStr[][size],intnum) { //Char *tmp; //int Top,seek; //For (top=0;top<num-1;top++) {//For (seek=top+1;seek<num;seek++) {//if (strcmp (Str[top], Str[seek]) > 0) {//tmp = Str[top]; //Str[top] = Str[seek]; //Str[seek] = tmp; // } // } //} inti; str[1][1]='*'; for(i=0; i<num;i++) {printf ("%s\n", Str[i]); }}
#include <stdio.h>#include<string.h>#defineSIZE 80#defineLMT 3#defineHALT ""/** * String sort function function prototype declaration*/voidStr_sort (Char*str[],intnum);intMain () {CharInput[lmt][size]; Char*PS[LMT]; intCT =0; intK; while(CT<LMT && gets (input[ct])! = NULL && input[ct][0] !=' /') {PS[CT]=INPUT[CT]; CT++; } str_sort (PS,CT); Puts ("Here is the res list:"); for(k=0; k<ct;k++) {puts (ps[k]); } return 0;}voidStr_sort (Char*str[],intnum) { Char*tmp; intTop,seek; for(top=0; top<num-1; top++){ for(seek=top+1; seek<num;seek++){ if(strcmp (Str[top], Str[seek]) >0) {tmp=Str[top]; Str[top]=Str[seek]; Str[seek]=tmp; } } }}
C language-pointer and pointer arrays to multidimensional arrays