Syntax:
#include <cstring> char *strcat( char *str1, const char *str2 );
The strcat function concatenates str2
onto the end of str1
, and returns str1
.
For example:
printf( "Enter your name: " ); scanf( "%s", name ); title = strcat( name, " the Great" ); printf( "Hello, %s\n", title );
Note that strcat does not perform bounds checking, and thus risks overrunning
str1
or str2
. For a similar (and safer) function that includes bounds checking,
see strncat.
Related Topics: strchr, strcmp, strcpy, strncat
Another set of related (but non-standard) functions are strlcpy and strlcat