If the task is only to copy 4 characters, try using loops. If it will be more advanced and you ask for a function, try strncpy. http://www.cplusplus.com/reference/clibrary/cstring/strncpy/
strncpy(sub1, baseString, 4); strncpy(sub1, baseString+4, 4); strncpy(sub1, baseString+8, 4);
or
for(int i=0; i<4; i++) sub1[i] = baseString[i]; sub1[4] = 0; for(int i=0; i<4; i++) sub2[i] = baseString[i+4]; sub2[4] = 0; for(int i=0; i<4; i++) sub3[i] = baseString[i+8]; sub3[4] = 0;
Prefer strncpy if possible.
holgac
source share