Concatenates str_2, including the terminating null character, to the end of str_1.
#include <string.h> char *strcat (char *str_1, const char *str_2);Function Variants This function also has variants named _strcat32 and _strcat64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.
x | The address of the first argument, str_1, which is assumed to be large enough to hold the concatenated result. |
#include <string.h> /* This program concatenates two strings using the strcat function, and * * then manually compares the result of strcat to the expected result. */ #define S1LENGTH 10 #define S2LENGTH 8 main() { static char s1buf[S1LENGTH+S2LENGTH] = "abcmnexyz"; static char s2buf[] = " orthis"; static char test1[] = "abcmnexyz orthis"; int i; char *status; /* Take static buffer s1buf, * * concatenate static buffer s2buf to it, * * and compare the answer in s1buf with * * the static answer in test1. */ status = strcat(s1buf, s2buf); for (i = 0; i <= S1LENGTH+S2LENGTH-2; i++) { /* Check for correct returned string. */ if (test1[i] != s1buf[i]) printf("error in strcat"); } }