Tech Study

Write C++ program to concatenate two strings

Introduction

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

 

Write C++ program to concatenate two strings
Write C++ program to concatenate two strings

TaggedWrite C++ program to concatenate two strings

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more