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<iostream>
#include<cstring>
using namespace std;

int main() {

    char str1[100], str2[100];

    cout << "Enter first string:";
    cin.getline(str1, 100);

    cout << "Enter second string:";
    cin.getline(str2, 100);

    strcat(str1, str2);

    cout << "Concatenated string is:" << str1;

    return 0;
}

Output:

Enter first string:Xiith
Enter second string:.com
Concatenated string is:Xiith.com