下面是我写的代码:
#include<stdio.h>
#include<stdlib.h>
#define COL_SIZE 4
#define RAW_SIZE 4
char ** get()
{
char ** charPoint2 = (char **)malloc(sizeof(char*)*COL_SIZE);
int i = 0;
for(i = 0; i < RAW_SIZE; i++)
{
*(charPoint2 + i) = (char *)malloc(sizeof(char)*COL_SIZE);
}
int j = 0;
for(i = 0; i < RAW_SIZE; i++)
for(j = 0; j < COL_SIZE; j++)
{
*(*(charPoint2 + i) + j) = (char)(i + j + 70);
}
return charPoint2;
}
int main()
{
char ** charPoint2 = get();
int i,j;
for(i = 0; i < RAW_SIZE; i++)
for(j = 0; j < COL_SIZE; j++)
{
putchar(*(*(charPoint2 + i) + j));
putchar(' ');
if (j == 3)
{
printf("\n");
}
}
return 0;
}
下面是输出的结果:
F G H I
G H I J
H I J K
I J K L