strncpy( )

The strncpy() function is used for copying the specified number of bytes from one string into another. Here is its syntax:

char * strncpy ( char * dest, const char *src, size_t numb);

Here's a breakdown of what the preceding code represents:

If the value of the numb parameter is larger than the length of the source string, the destination string will be padded with null bytes. If the length of the destination string is smaller than the numb parameter, then the string will be truncated to be equal to the length of the destination string.

Let's now begin our journey for secure coding with the first recipe.