C string strncat() function
Example
Concatenate part of a string:
char myStr[20] = "Hello";
strncat(myStr, " World!", 5);
printf("%s", myStr);
Try it Yourself »
Definition and Usage
The strncat()
function appends part of a string to the end of another. A number specifies the size of the part of the string to append.
The strncat()
function is defined in the <string.h>
header file.
Note: To append an entire string to another, use strcat()
instead.
Syntax
strncat(void * destination, void * source, size_t size);
The size_t
data type is a positive integer.
Parameter Values
Parameter | Description |
---|---|
destination | Required. A pointer to the string to append to. A copy of part of the source string will be appended at the position of the first null terminating character. |
source | Required. A pointer to the string to copy from. Data from the beginning of the string up to the position specified by the size parameter will be copied. |
size | Required. The number of characters to append to the destination string. |
Technical Details
Returns: | A char type pointer to the destination string. |
---|