I have a char array which contains some value . I want to copy the value from that array from some random index to some other random index . How can I do that ?
#include<iostream.h>
using namespace std;
int main()
{
char ar[100];
strcpy(ar,"string is strange");
cout << ar ;
return 0;
}
Now ar array contains "string is strange" . Suppose I want to make an another char array cp
in which I want to copy the value from random index position of ar
say from 7 to 10 . Is there some string function which we can use ?
I know we can use strncpy
function but it copies from starting index till number of characters mentioned . Is there some other function or an overloaded version of strncpy
which will enable me to perform the same?