Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct node {
- char *string;
- struct node *next;
- };
- struct node *sw1, *sw2, *sw1_head;
- //first 1 and first2 is the head of linked lists that holds text's each word seperatly. i created before.
- first1 = first1_head; // _ head is the same as first1 and first2
- first2 = first2_head;
- //sw1 and sw2 are the pointers that holds always second words.
- sw2 = first2->next;
- sw1 = first1->next;
- sw1_head = sw1;
- //these chars are used to concat two words
- char destination1[50];
- char destination2[50];
- while(sw2 != NULL){
- strcpy(destination2,first2->string);
- strcat(destination2,sw2->string);
- while(sw1 != NULL){
- strcpy(destination1,first1->string);
- strcat(destination1,sw1->string);
- // printf("%sn", destination1);
- if(strcmp(destination2, destination1) == 0) {
- insert(&matched2, destination1);//matched holds common words
- }
- sw1 = sw1->next;
- first1 = first1->next;
- }
- sw1 = sw1_head;//sets both sw1 and first1 to their past positions.
- first1 = first1_head;
- sw2 = sw2->next;
- first2 = first2->next;
- }
Add Comment
Please, Sign In to add comment