C++ Programming Code Examples C++ > Strings Code Examples C++ Programming Code to Copy String C++ Programming Code to Copy String To copy string in C++ programming, you have to ask to the user to enter the string to make copy to another variable say str2 of same type using function strcpy() and display the copied string on the output screen as shown here in the following program. Following C++ program ask to the user to enter the string to copy it into another string, then display the copied string on the screen : /* C++ Program - Copy String */ #include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> void main() { clrscr(); char str1[20], str2[20]; cout<<"Enter a string : "; gets(str1); cout<<"copying string 1 into string 2 ......\n"; strcpy(str2, str1); cout<<"String 2 after copying "<<str2; getch(); }