Re: how to remove a character from a string

From: Christopher Benson-Manica (ataru_at_nospam.cyberspace.org)
Date: 04/07/04


Date: Wed, 7 Apr 2004 21:14:24 +0000 (UTC)

Toto <max@nospam.com> spoke thus:

> "table+camera"
> and I want to remove the + sign:
> "tablecamera".

Well, I hope this isn't a homework question, because I'll post an
answer:

void rem_char( char *s, char t )
{
  if( !s || !*s ) return;
 
  while( *s++ != t ) if( !*s ) return;
  while( *(s-1)=*s++ );
}

I don't guarantee that it's conforming, but it produced correct
results for me.

-- 
Christopher Benson-Manica  | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org    | don't, I need to know.  Flames welcome.


Relevant Pages

  • [PATCH 2.6.19-rc1 V9] drivers: add LCD support
    ... Adds support for the ks0108 LCD Controller as a device driver. ... +The buffer should be a 128*64 unsigned char array: ... * GNU General Public License for more details. ... +static void cfag12864b_setbit ...
    (Linux-Kernel)
  • [PATCH 2.6.19-rc1 V9] drivers: add LCD support
    ... Adds support for the ks0108 LCD Controller as a device driver. ... +The buffer should be a 128*64 unsigned char array: ... * GNU General Public License for more details. ... +static void cfag12864b_setbit ...
    (Linux-Kernel)
  • Re: back once again...
    ... reference to type ... a, signed char ... int dycObjectP(dyt obj); ... void dycBeginClass; ...
    (comp.lang.misc)
  • [PATCH 2.6.18 V8] drivers: add LCD support
    ... Adds a LCD class for registering LCD devices. ... +The buffer should be a 128*64 unsigned char array: ... * GNU General Public License for more details. ... +static void cfag12864b_setbit ...
    (Linux-Kernel)
  • [PATCH 2.6.18 V7] drivers: add lcd display support
    ... Adds support for the cfag12864b LCD Display as a device driver. ... +The buffer should be a 128*64 unsigned char array: ... * GNU General Public License for more details. ... +static void cfag12864b_setbit ...
    (Linux-Kernel)