Program:
int x; int *y; int **z; z = (int **) malloc (sizeof(int *)); y = (int *) malloc (sizeof(int)); x = 1; *z = &x; *y = x; . . . Question: What is the difference between:
*z = &x; *y = x; From what I understand *z points to the address of x and *y points to x, but for *y to point to x doesn't that require the address of x? I don't really understand what's going on with these two variables.
Edit: I also want to know when do we know when a variable is allocated on the stack or on the heap?
- Why is x,y, and z allocated on the stack?
- Why is *y, **y, *z, **z, allocated on the heap?
Finally, does changing *z, change **z?



malloc()in C. This will help identify the bug of not having a prototype for it.