Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: