G
gxpcw
Unregistered / Unconfirmed
GUEST, unregistred user!
char __fastcall TpcForm::Ascii2Hex(char data)
{
int c;
if(data>'9')
c=toupper(data)-'A'+10;
else
c=data-0x30;
return((char)c);
}
void __fastcall TpcForm::Button3Click(TObject *Sender)
{
// AnsiString EditText=Edit1->Text;
Edit3->Text=Ascii2Hex(Edit1->Text);
//调用以上函数
}
运行时出错:[C++ Error] pcw.cpp(57): E2034 Cannot convert 'AnsiString' to 'char'
[C++ Error] pcw.cpp(57): E2342 Type mismatch in parameter 'data' (wanted 'char', got 'AnsiString')
如果把Edit3->Text=Ascii2Hex(Edit1->Text);改为:
Edit3->Text=Ascii2Hex(Edit1->Text.c_str());
运行时又出错:[C++ Error] pcw.cpp(57): E2034 Cannot convert 'char *' to 'char'
[C++ Error] pcw.cpp(57): E2342 Type mismatch in parameter 'data' (wanted 'char', got 'char *')
敬请高手指点!
{
int c;
if(data>'9')
c=toupper(data)-'A'+10;
else
c=data-0x30;
return((char)c);
}
void __fastcall TpcForm::Button3Click(TObject *Sender)
{
// AnsiString EditText=Edit1->Text;
Edit3->Text=Ascii2Hex(Edit1->Text);
//调用以上函数
}
运行时出错:[C++ Error] pcw.cpp(57): E2034 Cannot convert 'AnsiString' to 'char'
[C++ Error] pcw.cpp(57): E2342 Type mismatch in parameter 'data' (wanted 'char', got 'AnsiString')
如果把Edit3->Text=Ascii2Hex(Edit1->Text);改为:
Edit3->Text=Ascii2Hex(Edit1->Text.c_str());
运行时又出错:[C++ Error] pcw.cpp(57): E2034 Cannot convert 'char *' to 'char'
[C++ Error] pcw.cpp(57): E2342 Type mismatch in parameter 'data' (wanted 'char', got 'char *')
敬请高手指点!