strncat(3) CLIX strncat(3)
NAME
strncat - Appends a specified number of bytes from one string onto another
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <string.h>
char *strncat(
char * string1 ,
char * string2 ,
size_t number );
PARAMETERS
string1
A pointer to a character string
string2
A pointer to a character string
number The number of bytes to copy
DESCRIPTION
The strncat() function appends number bytes in the string pointed to by
the string2 parameter to the end of the string pointed to by the string1
parameter. The initial character of the string pointed to by string2
overwrites the null character at the end of the string pointed to by
string1. The number of characters specified by the number parameter and a
terminating null character are always appended to the string pointed to by
the string1 parameter.
EXAMPLES
#include <stdio.h>
#include <string.h>
#define MAX_NAME_LEN 10
main()
{
int remaining;
char name[MAX_NAME_LEN];
/* copy the first name to the array "name" */
strcpy(name, "jan");
2/94 - Intergraph Corporation 1
strncat(3) CLIX strncat(3)
/* see how many characters we have left in the array "name" */
/* The "1" is included so we will have room left for the NULL terminator */
remaining = MAX_NAME_LEN - strlen(name) - 1;
strncat(name, "meadows", remaining);
printf("The name is %s\n", name);
}
CAUTIONS
When operating on overlapping strings, the behavior of this function is
unreliable.
RELATED INFORMATION
Functions: index(3), rindex(3), strcat(3), strcmp(3), strcspn(3),
strchr(3), strcpy(3), strlen(3), strncmp(3), strncpy(3), strpbrk(3),
strrchr(3), strspn(3)
2 Intergraph Corporation - 2/94