strcat() prototype
char* strcat( char* dest, const char* src );
The
strcat() function takes two arguments: dest and src. This function appends a copy of the character string pointed to by src tocat() Parameters
dest: Pointer to a null terminating string to append to.
src: Pointer to a null terminating string that is to be appended.
strcat() Return value
The strcat() function returns dest, the pointer to the destination string.
Example: How strcat() function works
#include <cstring> #include <iostream> using namespace std; int main() { char dest[50] = "Learning C++ is fun"; char src[50] = " and easy"; strcat(dest, src); cout << dest ; return 0; }
When you run the program, the output will be:
Learning C++ is fun and easy