strncat
char * strncat ( char * dest, const char * src, sizet_t num ); | string.h |
cplusplus.com |
Append substring to string.
Appends num characters of src string to dest string.
If the terminating null-character appears in src string before num character
have been appended, the function appends the null-character to dest and ends.
The terminating null character in dest is overwritten by the first character
of src. The resulting string includes a null-character at end.
Parameters.
Return Value.
dest is returned.
Portability.
Defined in ANSI-C.
Example.
/* strncat example */
#include <stdio.h>
#include <string.h>
main ()
{
char str1[20];
char str2[20];
strcpy (str1,"To be ");
strcpy (str2,"or not to be");
strncat (str1, str2, 6);
puts (str1);
return 0;
}
Output:
To be or not
See also.
strcat,
strcpy,
strncpy
strset,
memcpy