Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. typedef struct unit {
  2. int data[20];
  3. struct unit *next;
  4. } unit;
  5.  
  6. unit *copy(unit *start) {
  7. unit *newstart, *newrunning;
  8. for (newstart = newrunning = NULL; start != NULL; start = start->next) {
  9. unit *p = (unit*)malloc(sizeof(unit));
  10. *p = *start;
  11. p->next = NULL;
  12. if (newstart==NULL)
  13. newstart = newrunning = p;
  14. else {
  15. newrunning->next = p;
  16. newrunning = newrunning->next;
  17. }
  18. }
  19. return newrunning;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement