3 ms·
What happens if you pass '\0' as the character to remove?
by zb 16y ago
What happens if you pass '\0' as the character to remove?
- ydant 16y agoLike the grandparent, I do the same. I have the copy routine also copy over the final 0. If you pass in 0 as the character to remove, it still works fine. Nothing is shifted, so the final 0 is copied and the string remains null terminated. Technically this could be undesirable behavior (it's contrary to the spec), but I don't think the behavior if you do pass in a 0 to remove could be easily defined. What does it copy into the place where the null was? How does it know where to stop? Easier to just assume it's remove any non-null character and asking to remove null means remove nothing.