Skip to main content

strncpy

Function strncpy 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn strncpy( s1: *mut c_char, s2: *const c_char, n: size_t, ) -> *mut c_char
Expand description

See https://pubs.opengroup.org/onlinepubs/9799919799/functions/strncpy.html.

Copies not more than n bytes (bytes that follow a NUL character are not copied) from the array pointed to by s2 to the array pointed to by s1.

If the array pointed to by s2 is a string that is shorter than n bytes, NUL characters shall be appended to the copy in the array pointed to by s1, until n bytes in all are written.

Returns s1.

§Implementation

Simply calls stpncpy and returns s1.

§Safety

If copying takes place between objects that overlap, the behaviour is undefined.