动态分配二维数组指针

#include <stdio.h>
#include <stdlib.h>

void main()
{
    int **pp = (int **)malloc(sizeof(int *)* 5);

    int num = 0;

    for (int i = 0; i < 5; i++)
    {
        pp[i] = (int *)malloc(sizeof(int)* 5);
        for (int j = 0; j < 5; j++)
        {
            printf("%4d", pp[i][j] = num++);
        }
        printf("\n");
    }

    system("pause");
}

 

posted @ 2016-01-24 16:37  喵小喵~  阅读(402)  评论(0编辑  收藏  举报