Q:

Copying from random position Within an array to another array

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? 

A:

Do like this
strncpy (dest, ar + 7, 2);

generally
strncpy (destination, source + start_index, number_of_chars);

   The strncpy() function is similar, except that at most n bytes of src are copied.  Warning: If there
   is no null byte among the first n bytes of src, the string placed in dest will  not  be  null-termi‐
   nated.

Therefore you need to null terminate the string manually:
dest[nos_of_chars] = '\0';

UPDATE
You can use something like this:
char *make_substring (char *src, int start, int end)
{
  int nos_of_chars = end - start + 1;
  char *dest;
  if (nos_of_chars < 0)
  {
    return NULL;
  }
  dest = malloc (sizeof (char) * (nos_of_chars + 1));
  dest[nos_of_chars] = '\0';
  strncpy (dest, src + start, nos_of_chars);
  return dest;
}

When you are using C++, do not use the char strings for processing instead use the string class.

