Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Recursive Character Search and Destroy

Name: Anonymous 2007-05-11 16:50 ID:tCgeez6Q

I receive a string, and I want to remove any 'a', 'b' and 'c' characters, in a recursive way.

How do I do this in C and Java?

Thanks

Name: Anonymous 2007-05-12 20:06 ID:+FERuxZR

>>44
void remove_char(char* s,char c){
 for(char*r=s;*s;*r=!s++)if(*s!=c)*r++=*s;
}


void remove_char(char*s,char c,char*r){
 if(!r)r=s;
 if(*s!=c)*r++=*s;
 *r=!s++;
 if(*s)return remove_char(s,c,r);
}


yeah, recursion makes it so much better.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List