You could do this a lot of ways, but I'd use a char array[] with a
size equal to the length of the subject string (including the end of
string null char '\0').

Then copy the subject string into the array[]. This would be the
"working" array[], where char's are deleted as they're found in the
pattern.

Now go through the working array[], and remove each occurrence of the
pattern char's. Remember to "close up" the remaining char's, either
after all the pattern char's have been removed, or you can do it after
each pattern char is removed. Otherwise you'll end up with things
like
"  r   d r ", as your final subject.

You'll need to include your string header file <string.h>, if this is
C.

I'll stress that this is neither the only, nor perhaps the best way of
doing this. It's just one way I've used in the past, in C. Find the
way that you are clear about using, and use that.

If you're need a hint with the algo or syntax, post back (and if it's
code related, show your code). If you want someone to code up your
homework, forget it.



On Aug 7, 9:00 am, "Arulanandan P" <[EMAIL PROTECTED]> wrote:
> You have to write a function whose prototype is given bellow. this function
> will accept two char * named subject and pattern. for example
> subject="abracadbra"
> and pattern="bca".now it should check occurrences of all chars of string
> pattern in subject . If any match occurs then it will remove that char from
> subject . so finally , as in our example
> at end subject ="rdr"
>
> void fun(char *subject,char *pattern)
> {
> // write your code here
>
> }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to