Thursday, September 27, 2018

string.h - Copy String to another string

#include<string.h>
#include<iostream>
using namespace std;
// Program to copy a string

main()
{
char str[100], str_copy[100];
cout<<"Enter a String ";
cin.getline(str,100);

cout<<str;
strcpy(str_copy,str);
cout<<"\n Original String = " <<str;
cout<<"\n Copied String = " <<str_copy;
}

No comments:

Post a Comment