One solution would be to use strncpy. You can specify the amount of characters to copy, and when you specify the source string, calculate the starting offset.
For example, for position 2 to 5, you'd use:
Code:
strncpy(dst, src + 1, 4);
We specify + 1 for position 2 because C arrays are zero based. The 4 is the number of characters between 2 and 5.
Remember that strncpy will NOT null terminate the string for you (unless you copy to the end of src (not in this case)), so you'd need an additional: afterward.
I'll leave it as an exercise for you to produce a function to do this. Example declaration:
Code:
void slice(char *dst, char *src, int start, int finish)
{
}
Of course dst will need to point to something capable of holding at least (finish - start + 2) elements.