I have a Listbox that contains strings of four words. When I click on one line, these words should be visible in four different text blocks. So far, everything works for me, but I have a problem with character conversion. The string from the list is UnicodeString, but strtok uses char []. The compiler says met Unable to convert UnicodeString to char []. This is the code I use for this:
{ int a; UnicodeString b; char * pch; int c; a=DatabaseList->ItemIndex; //databaselist is the listbox b=DatabaseList->Items->Strings[a]; char str[] = b; //This is the part that fails, telling its unicode and not char[]. pch = strtok (str," "); c=1; while (pch!=NULL) { if (c==1) { ServerAddress->Text=pch; } else if (c==2) { DatabaseName->Text=pch; } else if (c==3) { Username->Text=pch; } else if (c==4) { Password->Text=pch; } pch = strtok (NULL, " "); c=c+1; } }
I know that my code does not look beautiful, actually not bad. I am just learning some C ++ programs. Can someone tell me how to do this?
c ++ builder chars
Stefan oostwegel
source share