#include
#include
using namespace std;
int main() {
char str1[100], str2[100];
cout << "Enter a string: ";
cin.getline(str1, 100);
strcpy(str2, str1);
cout << "The copied string is: " << str2 << endl;
return 0;
}
Enter a string: www.freetimelearning.com
The copied string is: www.freetimelearning.com
str1
and str2
of size 100
.getline()
function.strcpy()
function to copy the contents of str1
to str2
.str2
using cout
.