C examples for string.h:strncat
function
<cstring> <string.h>
Appends the first num characters of source to destination, plus a terminating null-character.
char * strncat ( char * destination, const char * source, size_t num );
Parameter | Description |
---|---|
destination | Pointer to the destination array. |
source | C string to be appended. |
num | Maximum number of characters to be appended. |
destination is returned.
#include <stdio.h> #include <string.h> int main ()//ww w.j a v a 2 s. com { char str1[20]; char str2[20]; strcpy (str1,"To be "); strcpy (str2,"or not to be"); strncat (str1, str2, 6); puts (str1); return 0; }