string_remove_all_chars - only write if the character is not the
one to remove
This commit is contained in:
parent
02f3f31121
commit
954d202637
|
@ -495,9 +495,10 @@ void string_remove_all_chars(char *s, char c)
|
|||
|
||||
while (*read_ptr != '\0')
|
||||
{
|
||||
*write_ptr = *read_ptr++;
|
||||
if (*write_ptr != c)
|
||||
write_ptr++;
|
||||
/* Only write if the character is not the one to remove */
|
||||
if (*read_ptr != c)
|
||||
*write_ptr++ = *read_ptr;
|
||||
read_ptr++;
|
||||
}
|
||||
|
||||
*write_ptr = '\0';
|
||||
|
|
Loading…
Reference in New Issue