Q:

Write C++ program to concatenate two strings

belongs to collection: C++ language string programs

0

Write C++ program to concatenate two strings

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.

#include <iostream>
#include <cstring>
using namespace std;
 
int main()
{
    char s1[50], s2[50], result[100];
 
    cout << "Enter string s1: ";
    cin.getline(s1, 50); // Reading first string from user
 
    cout << "Enter string s2: ";
    cin.getline(s2, 50); // Reading second string from user
 
    strcat(s1, s2);  // strcat is use to Concatenates two strings
 
    cout << "String obtained on concatenation is:" << s1 << endl;
 
    return 0;
}

Result:

Enter string s1: tech

Enter string s2: study

String obtained on concatenation is:techstudy

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C++ program to find string length... >>