Safely using strncpy

This tip submitted by oliv29 on 2006-04-16 17:28:23. It has been viewed 17368 times.
Rating of 5.6 with 131 votes

when you use strncpy() always remember to add '\0' at the end of destination string. strncpy does not automatically add the terminator if the source string is longer than the destination!

More tips

Help your fellow programmers! Add a tip!