Header Ads

Header ADS

REPLACE A STRING IN ANOTHER STRING IN C++

#include <iostream>
#include <string.h>
using namespace std;

int main ()
{
    char S1 [1000];
    char S2 [1000];

    cout<<"PLEASE ENTER A STRING : ";
    cin>>S1;

    cout<<"PLEASE ENTER ANOTHER STRING : ";
    cin>>S2;

    cout<<"BEFORE THE 1ST STRING WAS : ";
    cout<<S1<<endl;

    cout<<"AND 2ND STRING WAS : ";
    cout<<S2<<endl;

    strcpy(S1,S2);

    cout<<"AFTER THE 1ST STRING IS : ";
    cout<<S1<<endl;

    return 0;
}
OUTPUT

No comments

Powered by Blogger.