示例:
#include <stdio.h> #include <stdlib.h> #include <string.h> char *ptrToptr(char *outside) { char *inside = NULL; inside = (char *)malloc(200 * sizeof(char)); strcpy(inside, "inside"); free(outside); return inside; } int main() { char *outside = NULL; outside = (char *)malloc(100 * sizeof(char)); strcpy(outside, "outside"); outside = ptrToptr(outside); printf("%s\n", outside); free(outside); } 