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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: