Re: how to remove a character from a string
From: Christopher Benson-Manica (ataru_at_nospam.cyberspace.org)
Date: 04/07/04
- Next message: jimjim: "Re: use delete to destroy primitive/object types but memory is not freed"
- Previous message: jimjim: "Re: use delete to destroy primitive/object types but memory is not freed"
- In reply to: Toto: "how to remove a character from a string"
- Next in thread: code_wrong: "Re: how to remove a character from a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Next message: jimjim: "Re: use delete to destroy primitive/object types but memory is not freed"
- Previous message: jimjim: "Re: use delete to destroy primitive/object types but memory is not freed"
- In reply to: Toto: "how to remove a character from a string"
- Next in thread: code_wrong: "Re: how to remove a character from a string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|