Advertisement

C++ Program to Copy the String || Code with Abuzar

 In this tutorial I will show you how to copy the string in C++


What is Copy String ?

In object oriented programming we are using a copy string because it helps us to our program repeat if you write a code many times but copy string will help you write only one time and use the Strcpy() function make a copy string , we can make copy the string in many types .


Example :

// C++ Program to copy the string 

#include<iostream>
using namespace std;
int main()
{
string a ,b ;
cout<<"Enter the new string "<<endl;
getline(cin,a);

b=a;

cout<<"\tfirst a =  "<<a<<endl;
cout<<"second b =  "<<b<<endl;
return 0;
}

When the above code is compiled or run it , then the output is 

Output  :

Enter the new string : new

first a =  new 
second b =  new

Copy the string in C++ Video : Click Here

 This is my YouTube channel : Click Here
  
 Playlist of C++(Full Course) : Click Here
 
 Playlist of C++(Program ) : Click Here


Please ! Write comment if you find anything incorrect in this article .

This article is contributed by Mohd Abuzar . If you like code with abuzar or contributed with us so mail at - abuzar.abuzar.mohd325@gmail.com

Post a Comment

2 Comments

  1. Really Great Post The Author is very well known about the topic. C++ Programming Complete Notes

    ReplyDelete
    Replies
    1. Thankyou, for visiting our Blog and give the response I hope you like it. and you will come again, You will learn C++ basic to advanced here.

      Delete

Do not Comment and any spam text