#include<stdio.h> #include<stdlib.h> void AllocateMemory(int **pGetMemory, int n) { int *p = (int*)malloc(sizeof(int) * n); if (p == NULL) { *pGetMemory = NULL; } else { *pGetMemory = p; } } int main() { int *arr = NULL; int len = 10; int i =
二级指针即“指向指针的指针”: 下面的实例代码创建了一个二级指针c int a = 5; int* b = &a; int** c = &b; 你不能这样 int a = 5; int** c = &a; 这样你会得到一个类型不兼容的警告 c5.c:16:18: warning: initialization from incompatible pointer type [enabled by default] const int** c = &a; ^ 你也可以像这样创建