Advertisement
Guest User

Untitled

a guest
Nov 27th, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. //This LOOKED like it worked but failed when trying to free()
  2. int *ptr = (int *) malloc(sizeof(int));
  3. int x = 42;
  4. ptr = &x;
  5. free(ptr);
  6.  
  7. //This is what I meant to do in the first place
  8. int *ptr = (int *) malloc(sizeof(int));
  9. int x = 42;
  10. *ptr = x;
  11. free(ptr);
  12.  
  13.  
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement