Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. p1 = (*headcopy);
  2. p2 = (*headcopy)->next;
  3. p = (*headcopy);//sets p to the place where head is pointing
  4.  
  5. for(i=1; i<(pokemon-1); i++){
  6. while(p2 != NULL){
  7.  
  8. i = strlen(p1->name);
  9. j = strlen(p2->name);
  10.  
  11. if(i>j){
  12. strcpy(temp->name, p1->name);
  13. strcpy(temp->type, p1->type);
  14. strcpy(temp->color, p1->color);
  15.  
  16. strcpy(p1->name, p2->name);
  17. strcpy(p1->type, p2->type);
  18. strcpy(p1->color, p2->color);
  19.  
  20. strcpy(p2->name, temp->name);
  21. strcpy(p2->type, temp->type);
  22. strcpy(p2->color, temp->color);
  23.  
  24. p1 = p1->next;
  25. p2 = p2->next;
  26. }else{
  27. p1 = p1->next;
  28. p2 = p2->next;
  29. }
  30. }
  31. }
  32.  
  33. if(p == NULL){
  34. printf("PPS is empty! Go catch 'em all!n");
  35. }else{
  36. while(p != NULL){ //condition to move p
  37. printf("nPokemon # %dnn", x);
  38. printf("Name: ");
  39. printf("%s n", p->name);//prints the value of name on every p
  40. printf("Type: ");
  41. printf("%s n", p->type);//prints the value of type on every p
  42. printf("Color: ");
  43. printf("%s n", p->color);//prints the value of color on every p
  44. printf("----------------------------------n");
  45. p = p->next;//moves p
  46. x++;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement