4 ms·
Interesting that so many solutions posted thus far use strlen(). My C is beyond rusty, but this is what I came up with; do/while is so underappreciated these d
by logic 16y ago
Interesting that so many solutions posted thus far use strlen().
My C is beyond rusty, but this is what I came up with; do/while is so underappreciated these days. (HN needs a "spoiler" formatting tag, methinks. :)
void condense_by_removing(char *z_terminated, char char_to_remove) {
char *pos = z_terminated;
do {
if (*z_terminated != char_to_remove)
*pos++ = *z_terminated;
} while (*z_terminated++ != 0);
}