Hacker News new | ask | show | jobs
by bio_end_io_t 2936 days ago
The author should've been wary of strncpy, because his solution is wrong.

"If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated."

So copying sizeof(dest)-1 will not append a NULL byte as the author implies. You'll have to do that manually.

1 comments

Article's solution is wrong, but at least the headline is right!