C Program to concatenate two strings using strcat function


In this program, You will learn how to concatenate two strings using strcat function in c.


strcat(str1, str2);

Example: How to concatenate two strings using strcat function in c.

#include<stdio.h>
#include<string.h>

int main() {

    char str1[100], str2[100];

    printf("Enter First String :");
    scanf("%[^\n]%*c", str1); 

    printf("Enter Second String :");
    scanf("%[^\n]%*c", str2); 
    
    strcat(str1, str2);

    printf("Concatenated String is: %s", str1);

    return 0;
}

Output:

Enter First String :Xiith
Enter Second String :.com
Concatenated String is: Xiith.com