1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #include<stdio.h> #include<stdlib.h> int change_ptr(int** ptr); int main() { int *p =NULL; printf("old p =%p\n",p); change_ptr(&p); printf("*p=%d\n",*p); printf("new p =%p\n",p);
return 0; } int change_ptr (int **ptr) { int *tmp = NULL; tmp = malloc(sizeof(int)); *tmp = 4 ; *ptr = tmp ; return 0; }
|