Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. void swap_recs(void *record1, void *record2)
  2. {
  3. //printf("hi\n");
  4. //record1=malloc(sizeof(Record));
  5. //record2=malloc(sizeof(Record));
  6. Record temp;
  7. temp.id = * (int *)(record1+0);
  8. strcpy(temp.name, (char *)(record1+sizeof(int)) );
  9. strcpy(temp.surname, (char *)(record1+sizeof(int) + 15*sizeof(char)) );
  10. strcpy(temp.city, (char *)(record1+15*sizeof(char) + 20*sizeof(char)) );
  11.  
  12. * (int *)(record1+0) = * (int *)(record2+0);
  13. strcpy((char *)(record1+sizeof(int)), (char *)(record2+sizeof(int)) );
  14. strcpy((char *)(record1+sizeof(int) + 15*sizeof(char)), (char *)(record2+sizeof(int) + 15*sizeof(char)) );
  15. strcpy((char *)(record1+15*sizeof(char) + 20*sizeof(char)), (char *)(record2+15*sizeof(char) + 20*sizeof(char)));
  16.  
  17. * (int *)(record2+0) = temp.id;
  18. strcpy( (char *)(record2+sizeof(int)), temp.name );
  19. strcpy((char *)(record2+sizeof(int) + 15*sizeof(char)), temp.surname );
  20. strcpy((char *)(record2+15*sizeof(char) + 20*sizeof(char)), temp.city );
  21.  
  22. //printf("sygkrina %d %s me %d %s \n", temp.id,temp.name, (char *)(record2+sizeof(int)) );
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement