mercredi 2 mai 2018

code problems convert string to chart execl

hello i had this error when i compile my code. the execl are for a file c++ who screen data in a LCD on a raspberry

SerialPort.cpp: In function ‘int main()’:
SerialPort.cpp:121:50: error: cannot convert ‘std::__cxx11::string {aka 
std::__cxx11::basic_string<char>}’ to ‘const char*’ for argument ‘2’ to ‘int 
execl(const char*, const char*, ...)’
   execl("/mondossier/programmeYacine", data, data);

And this is my main

main()
{
    std::string cmd = "0";
    while(true){
            std::cout << "Entrez Commande" << std::endl;
            std::cin >> cmd;
            SerialPort* comSerie = new SerialPort();
            comSerie->writeSerialPort(cmd);
            sleep(1);
            std::string data = comSerie->readSerialPort();
            std::cout << data << std::endl;
            execl("/mondossier/programmeYacine", data, data);
            delete(comSerie);
    }
}

Aucun commentaire:

Enregistrer un commentaire