Namespaces
Variants
Views
Actions

Difference between revisions of "c/string/byte/strncpy"

From cppreference.com
< c‎ | string‎ | byte
m (Text replace - "std::" to "")
m (Text replace - "example cpp" to "example c")
Line 25: Line 25:
  
 
===Example===
 
===Example===
{{example cpp
+
{{example c
 
  |
 
  |
 
  | code=
 
  | code=

Revision as of 15:44, 13 April 2012

Template:c/string/byte/sidebar

Defined in header <string.h>
char *strncpy( char *dest, const char *src, size_t count );

Copies at most count characters of the byte string pointed to by src (including the terminating null character) to character array pointed to by dest.

If count is reached before the entire string src was copied, the resulting character array is not null-terminated.

If, after copying the terminating null character from src, count is not reached, additional null characters are written to dest until the total of count characters have been written.

If the strings overlap, the behavior is undefined.

Contents

Parameters

dest - pointer to the character array to copy to
src - pointer to the byte string to copy from
count - maximum number of characters to copy

Return value

dest

Example

Template:example c

See also

Template:c/string/byte/dcl list strcpyTemplate:c/string/byte/dcl list memcpy