Namespaces
Variants
Views
Actions

strcat

From cppreference.com
< c‎ | string‎ | byte
Revision as of 01:48, 15 April 2013 by NiXman (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <string.h>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td >
char *strcat( char          *dest, const char          *src );
</td>

<td class="t-dcl-nopad"> </td> <td > (until C99) </td> </tr> <tr class="t-dcl ">

<td >
char *strcat( char *restrict dest, const char *restrict src );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C99) </td> </tr> Template:ddcl list end

Appends a byte string pointed to by src to a byte string pointed to by dest. The resulting byte string is null-terminated. If the strings overlap, the behavior is undefined.

Contents

Parameters

dest - pointer to the null-terminated byte string to append to
src - pointer to the null-terminated byte string to copy from

Return value

dest

Example

#include <string.h>
 
int main() {
    char str1[50] = "Hello ";
    char str2[50] = "World!";
    strcat(str1, str2);
    printf("%s\n", str1);
}

Output:

Hello World!

See also

Template:c/string/byte/dcl list strncatTemplate:c/string/byte/dcl list strcpy