Re: strip_char

From: Invincibill (bill@longboys.net)
Date: 12/18/98


ack...boy..that was lame..


Invincibill wrote:
>
> right off the top of my head..this may not work. didnt check it.
>
> char *strip_char(char mychar, char *intext) {
>
>   char *newtext;
>   int x,y;
>
>   CREATE(newtext, char, strlen(intext));
>
>   for(x=0,y=0;x<=strlen(intext);x++) {
>     if(intext[x] == mychar) {
>       x++;
>       continue;
>     }
>     newtext[y] = intext[x];
>     y++;
>   }
  newtext[y]='\0';
  return newtext;
> }
>
> I Chose No Name wrote:
> >
> > Okay.. I need a function that removes all instances of a certain char from a
> > string...
> > example:
> > ---
> > strip_char('~', text);
> > ---
> > would remove all ~ from the string "text"
> >
> > however.. i dun know how to do that :) i messed around wit it for a while and
> > i can't figure it out.. could someone give me some pointers on how to write a
> > function like this? thanks a bunch
> >
> >      +------------------------------------------------------------+
> >      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
> >      |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
> >      +------------------------------------------------------------+
>
> --
> reply to bill<@>longboys.net(remove the<>)
>       ...spam avoidance policy in effect.
> check out www.giftsgalore.com, lots 'o neat stuff there.
> GO JOHNNY!!! GO BILL!!!
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
>      +------------------------------------------------------------+

--
reply to bill<@>longboys.net(remove the<>)
      ...spam avoidance policy in effect.
check out www.giftsgalore.com, lots 'o neat stuff there.
GO JOHNNY!!! GO BILL!!!


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST