English
Language : 

CC78K4 Datasheet, PDF (218/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 10 LIBRARY FUNCTIONS
6-2 strcpy,
strncpy
Character String/Memory Functions
FUNCTION
The string function strcpy is used to copy the contents of one character string to another.
The string function strncpy is used to copy up to a specified number of characters from one character string to
another.
HEADER
string. h
FUNCTION PROTOTYPE
char *strcpy (char *s1, const char *s2);
char *strncpy (char *s1, const char *s2, size_t n);
Function
strcpy,
strncpy
Arguments
s1... Pointer to copy
destination array
s2 ... Pointer to copy source
array
n ... Number of characters to
be copied
Return Value
Value of s1
EXPLANATION
strcpy
• The strcpy function copies the contents of the character string pointed to by s2 to the array pointed to by s1
(including the terminating character).
• If s2 < s1 ≤ (s2 + Character length to be copied), the behavior of strcpy is not guaranteed (as copying starts
in sequence from the beginning, not from the specified string).
strncpy
• The strncpy function copies up to the characters specified by n from the string pointed to by s2 to the array
pointed to by s1.
• If s2 < s1 ≤ (s2 + Character length to be copied or minimum value of s2 + n – 1), the behavior of strncpy is
not guaranteed (as copying starts in sequence from the beginning, not from the specified string).
• If the string pointed by s2 is less than the characters specified by n, nulls will be appended to the end of s1
until n characters have been copied. If the string pointed to by s2 is longer than n characters, the resultant
string that is pointed to by s1 will not be null terminated.
218
User’s Manual U15556EJ1V0UM