#include <iostream> #include <string> #include <windows.h> using namespace std; void main() { int i, j; //指针数组 char *a[] = { "123","456","789" }; //二维数组 char b[3][4] = { "123","456","789" }; //malloc动态分配内存 int **p = (int **)malloc(3 * sizeof(int *)); for (i = 0; i < 3; i++) { p[i] = (int *)malloc(4 * sizeof(int)); for (j = 0; j < 4; j++) { p[i][j] = i + j; cout << p[i][j] << endl; } } //释放内存 for (i = 0; i < 3; i++) { free(p[i]); } free(p); system("pause"); }