4 つの単語の行を含むリストボックスを含むフォームがあります。1 行をクリックすると、これらの単語が 4 つの異なるテキスト ボックスに表示されます。これまでのところ、すべてが機能していますが、文字変換に問題があります。
リストボックスからの文字列は UnicodeString ですが、strtok は char[] を使用します。コンパイラは、「UnicodeString を Char[] に変換できません」と通知します。これは私がこれに使用しているコードです:
{
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;
}
}
私のコードが見栄えがよくないことはわかっていますが、実際にはかなり悪いです。私はC++でプログラミングを学んでいます。
どうすればこれを変換できますか?