Re:Maybe you shouldn't install new software for a bit
by anthk on Friday May 08, 2026 @11:43AM
(#48064752)
That's almost the first literal exercise with strings you'll learn with "The C prog lang 2nd ed" ebook. One of the most trivial cases among writting a word/space/tabs counting program (wc under Unix).
Re:Maybe you shouldn't install new software for a bit
by cratermoon on Friday May 08, 2026 @11:43AM
(#48064751)
I realize I may have made it seem like I was saying leftpad was a general-purpose library. My aside about it was to note that even widely used libraries can still have bugs. That’s orthogonal to their scope.
Both old and new versions return a string longer than `len` if the padding char is multiple characters, e.g. leftpad('a', 3, '&&&&') will be longer than 3. That feels like it shouldn't happen.