Converting Unicodestring to Char[]

strtok actually modifies your char array, so you will need to construct an array of characters you are allowed to modify. Referencing directly into the UnicodeString string will not work.

// first convert to AnsiString instead of Unicode.
AnsiString ansiB(b);  

// allocate enough memory for your char array (and the null terminator)
char* str = new char[ansiB.Length()+1];  

// copy the contents of the AnsiString into your char array 
strcpy(str, ansiB.c_str());  

// the rest of your code goes here

// remember to delete your char array when done
delete[] str;