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

Run it Now
#include<stdio.h>
#include<string.h>

int main() {

    char str1[100], str2[100];

    printf("Enter First String :");
    fgets(str1, 100, stdin);
    strtok(str1, "\n");

    printf("\nEnter Second String :");
    fgets(str2, 100, stdin);

    strcat(str1, str2);

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

    return 0;
}

Output:

Enter First String :John
Enter Second String :Smith
Concatenate String is: JohnSmith