Definition | #include <string.h> char *strncat(char *s1, const char *s2, size_t n);
The null byte (\0) at the end of string s1 is overwritten by the first character of string s2. If string s2 contains less than n characters, only the characters from s2 are appended to s1. |
Return val. | Pointer to the result string.
|
Notes | Strings terminated with the null byte (\0) are expected as arguments.
The behavior is undefined if memory areas overlap. |
Example | #include <string.h>
#include <stdio.h>
int main(void)
{
char text1[BUFSIZ];
char text2[BUFSIZ];
int n;
printf("Example of strncat - please enter 2 text lines and n!\n");
if(scanf("%s %s %d", text1, text2, &n) == 3)
printf("%s\n", strncat(text1, text2, n));
return 0;
}
|
See also | strcat |