Guest User

Untitled

a guest
Oct 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. struct node {
  2. char *string;
  3. struct node *next;
  4. };
  5.  
  6. struct node *sw1, *sw2, *sw1_head;
  7.  
  8. //first 1 and first2 is the head of linked lists that holds text's each word seperatly. i created before.
  9.  
  10. first1 = first1_head; // _ head is the same as first1 and first2
  11. first2 = first2_head;
  12.  
  13. //sw1 and sw2 are the pointers that holds always second words.
  14. sw2 = first2->next;
  15. sw1 = first1->next;
  16. sw1_head = sw1;
  17.  
  18. //these chars are used to concat two words
  19. char destination1[50];
  20. char destination2[50];
  21.  
  22. while(sw2 != NULL){
  23.  
  24. strcpy(destination2,first2->string);
  25. strcat(destination2,sw2->string);
  26.  
  27. while(sw1 != NULL){
  28.  
  29. strcpy(destination1,first1->string);
  30. strcat(destination1,sw1->string);
  31. // printf("%sn", destination1);
  32. if(strcmp(destination2, destination1) == 0) {
  33.  
  34. insert(&matched2, destination1);//matched holds common words
  35.  
  36. }
  37.  
  38. sw1 = sw1->next;
  39. first1 = first1->next;
  40.  
  41. }
  42.  
  43. sw1 = sw1_head;//sets both sw1 and first1 to their past positions.
  44. first1 = first1_head;
  45. sw2 = sw2->next;
  46. first2 = first2->next;
  47. }
Add Comment
Please, Sign In to add comment