- #1
camel-man
- 76
- 0
int *p=malloc(sizeof(int));
and
int x;
int*p=&x;
I know that if you take the second one and print p it gives the address of x correct?
now what I want to know is when I malloc a pointer what address does it hold?? does it still hold the local address of p? Since I am not pointing it to a variable does malloc create memory that has an address and point it to that address on the heap?
and
int x;
int*p=&x;
I know that if you take the second one and print p it gives the address of x correct?
now what I want to know is when I malloc a pointer what address does it hold?? does it still hold the local address of p? Since I am not pointing it to a variable does malloc create memory that has an address and point it to that address on the heap?