welibc
A clear, secure, and well documented standard C library
Functions
strncpy.c File Reference

Defines the strncpy function. More...

#include <string.h>
Include dependency graph for strncpy.c:

Go to the source code of this file.

Functions

char * strncpy (char *s1, const char *s2, size_t n)
 Copies no more than n characters with null terminator from s2 to s1. More...
 

Detailed Description

Defines the strncpy function.

Definition in file strncpy.c.

Function Documentation

◆ strncpy()

char* strncpy ( char *  s1,
const char *  s2,
size_t  n 
)

Copies no more than n characters with null terminator from s2 to s1.

Parameters
*s1The destination array
*s2The source string
nMaximum number of characters to copy

The strncpy function copies not more than n characters (characters that follow a null character are not copied) from the array pointed to by s2 to the array pointed to be s1. If the array pointed to by s2 is a string that is shorter than n characters, null characters are appended to the copy in the array pointed to by s1, until n characters in all have been written.

Note
Copying between overlapping objects is supported, but the source may be overwritten.
Returns
The value of s1

Definition at line 58 of file strncpy.c.

References memmove(), memset(), strcpy(), and strlen().

Here is the call graph for this function: