2 ms·
His solution is so similar to mine that is scary. I also went thru the same optimization process. (e.g started with a while and changed that to a for later) I d
by huherto 16y ago
His solution is so similar to mine that is scary. I also went thru the same optimization process. (e.g started with a while and changed that to a for later) I didn't go farther because I didn't want to loose readability.
void condense_by_removing(
char *z_terminated ,
char char_to_remove
) {
char *rptr = z_terminated; // read ptr
char *wptr = z_terminated; // write ptr
for(;*rptr; rptr++) {
if (*rptr != char_to_remove) {
*wptr++ = *rptr;
}
}
*wptr = 0;
}