std::strncpy
If, after copying the terminating null character from src, count is not reached, additional null characters are written todest until the total of count characters have been written.
If the strings overlap, the behavior is undefined.
Parameters
dest pointer to the character array to copy tosrc pointer to the byte string to copy from
count maximum number of characters to copy
Return value
dest
Example
1 #include2 #include 3 using namespace std; 4 5 int main () 6 { 7 char str1[]= "To be or not to be"; 8 char str2[6]; 9 strncpy (str2,str1,5);10 str2[5]='\0';11 cout<
Output:
1 To be