Write a C++ program to concatenate two strings entered by the user.
Program Code:
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
char str1[40], str2[20];
cout<<"Enter your first string : ";
gets(str1);
cout<<endl;
cout<<"Enter your second string : ";
gets(str2);
cout<<endl;
strcat(str1, str2);
cout<<"String after concatenation string1 and string2 is : "<<str1;
return 0;
}
The program output is tested on www.jdoodle.com
Output:
Enter your first string : Mukesh
Enter your second string : Suruchika Rajput
String after concatenation string1 and string2 is : MukeshSuruchika Rajput
Thanks
Mukesh Rajput
Post A Comment:
0 comments: