首页 > 代码库 > 5.二级指针

5.二级指针

 

一.二级指针的输入模型

#include <stdlib.h>#include <string.h>#include <stdio.h>#pragma warning(disable:4996)int printArray(char **pArray, int num){    if (pArray == NULL)    {        return -1;    }    int i = 0;    for (i = 0; i < num;i++)    {        printf("myArray[%d] = %s\n", i, pArray[i]);    }    return 0;}void main() {    int i = 0, j = 0;    char *temp = NULL;    char * myArray[] = {"aaaaa","bbbbb","ccccc","1111111111"};    printf("打印前......\n");    /*for (i = 0; i < 4; i++)    {        printf("myArray[%d] = %s\n",i,myArray[i]);    }*/        printArray(myArray,4);    for (i = 0; i < 4; i++)    {        for (j = i + 1; j < 4; j++)        {            if (strcmp(myArray[i], myArray[j]) > 0)            {                temp = myArray[i];                myArray[i] = myArray[j];                myArray[j] = temp;            }        }    }    printf("打印后......\n");    /*for (i = 0; i < 4; i++)    {        printf("myArray[%d] = %s\n", i, myArray[i]);    }*/    printArray(myArray, 4);        system("pause");}

打印结果:

技术分享

 

5.二级指针