C strcat()

The function strcat() concatenates two strings.

In C programming, strcat() concatenates (joins) two strings.

The strcat() function is defined in <string.h> header file.


C strcat() Prototype

char *strcat(char *dest, const char *src)

It takes two arguments, i.e, two strings or character arrays, and stores the resultant concatenated string in the first string specified in the argument.

The pointer to the resultant string is passed as a return value.


Example: C strcat() function

#include <stdio.h>
#include <string.h>
int main()
{
    char str1[] = "This is ", str2[] = "programiz.com";

    //concatenates str1 and str2 and resultant string is stored in str1.
    strcat(str1,str2);

    puts(str1);    
    puts(str2); 

    return 0;
}

Output

This is programiz.com
programiz.com