strcat [C++ Reference]
Keywords: c,string,strcat
Date: 2009-04-06T11:13:00-0700

[[strcat]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## strcat

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

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •