I am trying to split up an array (string1) of n characters into two character pointers representing i characters (char* first) and n-i characters (char* second) respectively. For the second array, I used
char* second = string1+n;
What I am wondering is how to use only the first i characters in first. I do not want to allocate more memory for the two arrays, I want to manipulate string1 so that I just point to parts of what is already there.
EDIT:
I cannot edit string1. Can I just cast first somehow to make the length shorter without adding a null character?
strndup(), which takes a length, to only copy a certain portion of it and have memory allocated automatically.