Embedded Artistry Framework
Embedded Systems C++ Framework
Functions
strncpy.c File Reference
#include <string.h>
Include dependency graph for strncpy.c:

Functions

char * strncpy (char *__restrict dst, const char *__restrict src, size_t maxlen)
 Copies at most maxlen characters of the character array pointed to by src to character array pointed to by dest. More...
 

Function Documentation

◆ strncpy()

char* strncpy ( char *__restrict  dst,
const char *__restrict  src,
size_t  maxlen 
)

Copies at most maxlen characters of the character array pointed to by src to character array pointed to by dest.

Copies at most maxlen characters of the character array pointed to by src (including the terminating null character, but not any of the characters that follow the null character) to character array pointed to by dest. If maxlen is reached before the entire array src was copied, the resulting character array is not null-terminated. If, after copying the terminating null character from src, maxlen is not reached, additional null characters are written to dest until the total of maxlen characters have been written.

The behavior is undefined if the character arrays overlap, if either dest or src is not a pointer to a character array (including if dest or src is a null pointer), if the size of the array pointed to by dest is less than maxlen, or if the size of the array pointed to by src is less than maxlen and it does not contain a null character.

Parameters
dstpointer to the character array to copy to
srcpointer to the character array to copy from
maxlenmaximum number of characters to copy
Returns
a copy of dest

References memcpy(), memset(), and strnlen().

Referenced by strncpy_test().

Here is the caller graph for this function: