#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char key[25], buffer[25];
cout << "Enter the key string: ";
cin.getline(key, 25);
strcpy(buffer, key);
cout << "Key = "<< key << endl;
cout << "Buffer = "<< buffer<<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> v1 ={1,2,3,4,7,6,6,8,9};
vector<int> v2 ={10,11,12,13,14,15};
copy(v1.begin(),v1.begin()+3,v2.begin()+2);
for(auto i:v2)
{
cout<<i<<" ";
}
return 0;
}
//use '=' to copy string
string s1={"Hello"};
string s2;
s2=s1; //now s2 will have a copu s1
#include <iostream>
#include <string.h>
/*
std::copy(void *, void *, void *)
1st arg: source begin
2nd arg: source end
3rd arg: destination address
*/
int main()
{
char *mystring{new char[20]{}};
strcat(mystring, "Its Grepper");
char *deststring{new char[20]{}};
strcat(deststring, "Hello ");
std::copy(mystring + 4, mystring + 12, deststring + strlen(deststring));
std::cout << deststring << std::endl;
delete[] mystring;
delete[] deststring;
/*
output : Hello Grepper
*/
}