C++ strncat() Function

C++ strncat()

The strncat() function concatenates a copy of source string to destination string up to the specified length and terminates destination string with a null.

The null terminator originally ending destination is overwritten by the first character of source string.

If the array overlap, the behavior of strncat() is undefined.

Remember, no bounds checking takes place, so it is the programmer's responsibility to ensure that the size of the destination string variable is large enough to hold both its original contents and also those of source string.


C++ Compiler
#include <cstring> #include <iostream> using namespace std; int main() { char src[50] = ".com is awesome"; char dest[50] = "wikimass"; strncat(dest, src, 11); cout << dest ; return 0; }


char *strcat(char *dest, const chart *src, size_t n)

Parameter Values

destRequiredSpecifies the destination string.
srcRequiredSpecifies the source string.
nRequiredSpecifies the length of the characters to be concatenated.

Return Value

AddressReturns the pointer to the destination string.

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author