C++ Program to copy string using strcpy() function


In this program, You will learn how to copy string using strcpy() function in C++.


char ch = strcpy(second, first);


Example: How to copy string using strcpy() function in C++

Run it Now
#include<iostream>
#include<cstring>
using namespace std;

int main() {

    char first[100];
    char second[100];

    cout << "Enter String value :";
    cin.getline(first, 100);

    strcpy(second, first);

    cout << "\nThe first value is :" << first;
    cout << "\nThe Second Copy value is :" << second;

    return 0;
}

Output:

Enter String value :Xiith
The first value is :Xiith
The Second Copy value is :Xiith