snprintf() has better string behavior than strncpy(). See:

http://blog.liw.fi/posts/strncpy/