i need to know how can i split a string of characters into two.
i have one str[8] array and want two str1[4] and str2[4] arrays with str1 having the first half of str and str2 the rest.
how can i accomplish this?
i need to know how can i split a string of characters into two.
i have one str[8] array and want two str1[4] and str2[4] arrays with str1 having the first half of str and str2 the rest.
how can i accomplish this?
You can use strncpy library function.
But don't forget that your arrays must have room for the end of string characters. So with a string of size 8 at least one of the "split" strings must have a size of at least 5. Since a string of size 8 can have at most 7 characters, you would end up with string lengths of 3 and 4, which would require array sizes of 4 and 5.
Jim