Write C++ program to concatenate two strings


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

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


  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char s1[50], s2[50], result[100];
  8.  
  9. cout << "Enter string s1: ";
  10. cin.getline(s1, 50); // Reading first string from user
  11.  
  12. cout << "Enter string s2: ";
  13. cin.getline(s2, 50); // Reading second string from user
  14.  
  15. strcat(s1, s2); // strcat is use to Concatenates two strings
  16.  
  17. cout << "String obtained on concatenation is:" << s1 << endl;
  18.  
  19. return 0;
  20. }
  21.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts