c - Two strings input - removing common words from the 1st one and printing it -


So here it goes: I need to get two strings from the user, string 1 and string 2, then the word " "Delete String 1 which is also present in String 2 and prints in String 1.

I can token to them, but then I'm out of ideas / knowledge, need help :)

  int main {four string 1 [100] ; // Announcing the array for the first input four characters * Token 1 [100]; // Parent's array declaration * token_ptr1; // Pointer Wear to store four strokes to hook [2 2] [100]; // Array Announcement for First Input Four Characters * Token 2 [100]; // Parent's array announces four * token_ptr2; // pointer var to store tokens int i = 0; // Input from user: printf ("Enter 1 string:"); Gets (string1); Printf ("\ n"); Printf ("Enter String 2:"); Gets (string2); Printf ("\ n"); Using the strtok function to mark / String1 token_ptr1 = strtook (string 1, ""); printf ("token 1: \ n"); // Loop to store tokens of point and structure tokens (string1! = '\ 0') {if (token_ptr1 == '\ 0') {break; } Printf ("% s \ n", token_ptr1); tokens1 [i] = token_ptr1; Token_ptr1 = strtok (NULL, ""); I ++; } // string1 is stored in tokens and tokens 1}   

After this I have tried several ways to remove the common word without any profit

Edit: The same question within another problem:

Example INPUT1: This is a string 234

- Example INPUT2: 234

- Example output: This is a string

Using the tokening method string is saved in the string of "string234" pointers, now how to go to this program Aa? Examining individual characters using simple arrays?

Simple way to clamp both stars and assign them to loop and string 2 through string 1 through each token Have to compare with. If the token matches, you remove it token 1 by marking it.

Make another string token and make an array to mark each token from string 1. If the match is found then you mark the token 1 index and in the end you do not mark the token only, I can use a match function like this:

  int match ( Int ind1, int ind2) {while (string1 [ind1]! = '0') {if (string2 [ind2] == string 1 [ind1]) {ind2 ++; Ind1 ++; } And {break} }} // Check that string 2 also ends at the same position if (string 1 [indi] == string 2 [ind 2]) returns 1; Return 0; }   

Not tested it, but I think it's right. I hope this will work!

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -