Since function1 doesn't see the changes either, your question makes no sense.
Code:
Code:
include <stdio.h>
#include <stdlib.h>
void function2(int *ptr) {
ptr = malloc(5 * sizeof(int));
printf("function2 just happened to ptr %p.\n", ptr);
}
void function1(int *ptr) {
printf("ptr is %p.\n", ptr);
function2(ptr);
printf("ptr is now %p.\n", ptr);
}
int main(void) {
int *bob = NULL;
printf("bob initialized to %p.\n", bob);
function1(bob);
printf("bob is finally %p.\n", bob);
return 0;
}
Output:
Code:
$ ./temp
bob initialized to 0x0.
ptr is 0x0.
function2 just happened to ptr 0x100160.
ptr is now 0x0.
bob is finally 0x0.