Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int *x = (int *)malloc(4);
- *x = 20;
- int *y = x;
- printf("%d %d", *x, *y);
- free(x);
- printf("%d %p", *x, x); // x still have to value allocated using malloc
- *y = 100;
- // Changing the y value changes the x value even though it is unallocated
- printf("%d %d", *x, *y);
- 20 20
- 20 0x7fe921d00e70
- 100 100
Add Comment
Please, Sign In to add comment