Guest User

Untitled

a guest
Jul 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. int *x = (int *)malloc(4);
  2. *x = 20;
  3. int *y = x;
  4. printf("%d %d", *x, *y);
  5. free(x);
  6. printf("%d %p", *x, x); // x still have to value allocated using malloc
  7. *y = 100;
  8. // Changing the y value changes the x value even though it is unallocated
  9. printf("%d %d", *x, *y);
  10.  
  11. 20 20
  12. 20 0x7fe921d00e70
  13. 100 100
Add Comment
Please, Sign In to add comment