Just a note to point out that the test of printf-ing the result of a strncpy is not sufficient to show that it stops copying at the null byte (contrary to my previous statement). It is necessary to check what character is in the target string after the null. As my previous message shows, this is in fact a null, showing that copying does stop at the null byte.