The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

strncpy - copy part of a string

 SYNOPSIS



#include <string.h>

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

 DESCRIPTION

The strncpy() function copies not more than n bytes (bytes that follow a null byte are not copied) from the array pointed to by s2 to the array pointed to by s1. If copying takes place between objects that overlap, the behaviour is undefined.

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

 RETURN VALUE

The strncpy() function returns s1; no return value is reserved to indicate an error.

 ERRORS

No errors are defined.

 EXAMPLES

None.

 APPLICATION USAGE

Character movement is performed differently in different implementations. Thus overlapping moves may yield surprises.

If there is no null byte in the first n bytes of the array pointed to by s2, the result will not be null-terminated.

 FUTURE DIRECTIONS

None.

 SEE ALSO

strcpy(), <string.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]