C ++ error: E2034 Can not convert 'wchar_t *' to 'const char *'

1

When running a C ++ code these two problems occur:

- [BCC32 Error] USerialCommunication.cpp(96): E2034 Cannot convert 'wchar_t *' to 'const char *'
- [BCC32 Error] USerialCommunication.cpp(96): E2342 Type mismatch in parameter '__src' (wanted 'const char *', got 'wchar_t *')  

Source Code:

void __fastcall TFSerialPort::EnviarClick(TObject *Sender)
{
        char buff[100];    
        //Converte uma string em array.
        strcpy(buffer, EdCommand->Text.c_str());
}

EdCommand statement: TEdit *EdCommand;

Buffer declaration: char buffer[100];

Error occurs on line of strcpy .

Note: The source code was made in C ++ Builder 6 and I'm trying to run it on Embarcadero XE2

    
asked by anonymous 10.09.2014 / 23:59

1 answer

1

To solve, I've converted to AnsiString:

Before:

strcpy(buffer, EdCommand->Text.c_str());

Then:

strcpy(buffer, AnsiString(EdCommand->Text).c_str());
    
11.09.2014 / 04:28