I have a char array like "abc:def:ghi#jkl:mno:pqr#stu:vxz:wyk" which I want to split firstly by "#", then each of the resulted char array by ":". So I have something like this:
With this code only three messageboxes shows up, with, 'abc', 'def' and 'ghi'. What I want is that after splitting the largechars by "#" into chars_array (which would containt three elements), those three resulted elements should be splitted each one by ":" into subchar_array (which would contain three elements). If I keep only:
'def:def:def', then 'abc:abc:abc', then 'ghi:ghi:ghi' is shown by MessageBox but when I try to split each of them then only the first one is splitted. What do you recommend? Thanks!
First, you're modifying a read-only string, your first line of code must be char largechars[] = "def:def:def#abc:abc:abc#ghi:ghi:ghi";
I recommend using C++ language facilities (stringstream and getline, for example), or, to make it completely trivial, the boost library, but if you must do it with strtok, you will need to tell strtok about the beginning of each of the three subarrays: