Pointer to the destination null-terminated string where the source string will be appended.
2nd Parameter Type : const char *
Pointer to read-only string
2nd Parameter
Pointer to the null-terminated source string to append to `dest`.
3rd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
3rd Parameter
The maximum number of characters to append from `src`, excluding the null terminator.
Read more about parameters of strncat in parameters section
The strncatfunction in C language Appends a specified number of characters from the source string to the destination string.
The strncat function appends not more than n characters from the string pointed to by src to the end of the string pointed to by dest. The first character of src overwrites the null character at the end of dest. A terminating null character is always appended to the result.
The strncatfunction takes 3
parameters:
•
char * `dest`: Pointer to the destination null-terminated string where the source string will be appended.
•
const char * `src`: Pointer to the null-terminated source string to append to `dest`.
•
size_t `n`: The maximum number of characters to append from `src`, excluding the null terminator.
Appends up to `n` characters from the source string `src` to the destination string `dest`. A null terminator is added to the resulting string. The destination string must have enough space to hold the result. Returns a pointer to the destination string `dest`.
The strncat function return value :
Returns a pointer to the resulting string dest
Output
This example demonstrates basic usage of strncat to append the first 5 characters of 'World!' to 'Hello, '.