I am trying to use strncpy to only copy part of a string to another string in C.
Such as:
c[] = "How the heck do I do this";
Then copy "do this"
to the other string, such that:
d[] = "do this"
Help is appreciated.
Just pass the address of the first letter you want to copy: strcpy(dest, &c[13])
.
If you want to end before the string ends, use strncpy
or, better, memcpy
(don't forget to 0-terminate the copied string).