Advertisement

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 find the ASCII value of a character in C++

#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 << "First value is:" << first;
    cout << "\nSecond Copy value is:" << second;

    return 0;
}

Output:

Enter string value:Xiith.com
First value is:Xiith.com
Second Copy value is:Xiith.com