I want to split a string after a specific number of characters.
ie. split after the 5th character (position 5)
string s = "0123456789";
into
"012345" and "6789"
I don't have any consistent separator. I have a consistent amount of characters after which I want to split.
Split function won't work because by default it will set space as the separator if none is specified.
My approach would be.
Split the string into a characters array, and then recreate the separated strings using a for loop
string s_char[] => (0, 1, 2, 3 , 4, 5, 6 , 7, 8, 9)
int coord = 5; //coord to split at
string s_1, s_2;
for(int i; i <= coord; i++){
s_1 += s_char[i];
}
for(int i; i>coord && i<max; i++){
s_2 += s_char[i];
}
Any ideas on how to achieve this?