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

I prefer strcpy to strncpy, and make sure that the string will fit before the call. I use strncpy if I want to copy n characters from s2 to s1, strncpy can give a false sense of security imo since it may not add a terminating zero, for example using strncpy with strlen. The BSD strlcpy does always null terminate the string, but it's non standard.


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

Search: