c++ programs examples

C++ program to copy one string to another and display the two strings

c++ programs examples
/* 17. Write a C++ program to copy one string to another and display
       the two string */

 #include<iostream.h>
 #include<conio.h>
 #include<string.h>
 void main()
 {
  clrscr();
  char s1[10],s2[10];
  cout<<"Enter one string for s1"<<endl;
  cin>>s1;
  cout<<"The Entered string is for s1 ="<<s1<<endl;
  strcpy(s2,s1);
  cout<<"After copied s1 to s2, s2 ="<<s2;
  getch();
    }

Leave a Reply

Your email address will not be published. Required fields are marked *