Advertisement
BenLarge1

addItem

Apr 7th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. {
  2. Players *ptr = list;
  3. while(ptr != NULL) //runs until the list reaches NULL
  4. {
  5. if (strcmp(ptr->name, p) == 0) //if the name and player are the same, keep going
  6. {
  7. Items *ptr2 = (Items *)malloc(sizeof(Items));
  8. Items *ptr3 = ptr->things;
  9. while(ptr3 !=NULL) //keeps running until ptr = NULL
  10. {
  11. if (strcmp(ptr3->name, item)==0) //Got this part from a friend, no clue what this does until line 65
  12. {
  13. ptr3->count += num;
  14. return;
  15. }
  16. else
  17. {
  18. ptr3 = ptr3->next; //if they don't match keep going through the list
  19. }
  20. }
  21. ptr2->name = item;
  22. ptr2->count = num;
  23. ptr2->next = ptr->things;
  24. ptr->things = ptr2;
  25. return;
  26.  
  27. }
  28. ptr= ptr->next;
  29. }
  30. return;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement