Guest User

Untitled

a guest
May 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. char[] str = "foo-bar";
  2. memcpy(&str[3],&str[4],4); //might blow up
  3.  
  4. memmove(&str[3],&str[4],4); //fine
  5.  
  6. int SIZE = 100;
  7. Item *ptr_item = (Item *) malloc(size_of(Item) * SIZE);
  8. Item *ptr_src_item = ptr_item + 1;
  9. Item *ptr_dst_item = ptr_item;
  10. memmove(ptr_dst_item, ptr_src_item, SIZE - 1);
  11.  
  12. int SIZE = 100;
  13. Item *ptr_src_item = (Item *) malloc(size_of(Item) * SIZE);
  14. Item *ptr_dst_item = (Item *) malloc(size_of(Item) * (SIZE - 1));
  15. memcpy(ptr_dst_item, ptr_src_item, SIZE - 1);
Add Comment
Please, Sign In to add comment