Write a C++ program to copy first string into second string, where first string is entered by the user.
Program Code:
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
char str1[25], str2[25];
cout<<"Enter a string to copy into another string : ";
gets(str1);
cout<<endl;
cout<<"Copying string1 into string2 : ";
cout<<endl;
strcpy(str2, str1);
cout<<"String2 after copying String1 into it is : "<<str2;
return 0;
}
The program output is tested on www.jdoodle.com
Output:
Enter a string to copy into another string : Mukesh Rajput
Copying string1 into string2 :
String2 after copying String1 into it is : Mukesh Rajput
Thanks
Mukesh Rajput
Post A Comment:
0 comments: