Stack Exchange
Incorrect assignment from a QStringList to a char * array
    //This is my partial code.
    
    const char *MyparamValuesTagliando[16] = {nullptr};
    QString RigaDaCaricare;
    QStringList ListaElementiRiga;
    
    const int Destinatario = 0;
    const int Presso = 1;
    const int Toponimo = 2;
    const int Comune = 3;
    const int Cap = 4;
    const int Provincia = 5;
    const int Civico = 6;
    const int RifPratica_NumSinistro = 7;
    const int Note = 8;
    
    //RigaDaCaricare is a line of a .txt file
    //Something like "pippo;pluto;paperino;minni"
    ListaElementiRiga = RigaDaCaricare.split(";");
    
    //Some of the following assignments are OKs (I find the string I'am expecting) others KOs (strange characters)
    MyparamValuesTagliando[2] = ListaElementiRiga.at(Destinatario).toStdString().c_str();
    MyparamValuesTagliando[3] = ListaElementiRiga.at(Toponimo).toStdString().c_str();
    MyparamValuesTagliando[4] = ListaElementiRiga.at(Civico).toStdString().c_str();
    MyparamValuesTagliando[5] = ListaElementiRiga.at(Comune).toStdString().c_str();
    MyparamValuesTagliando[6] = ListaElementiRiga.at(Provincia).toStdString().c_str();
    MyparamValuesTagliando[7] = ListaElementiRiga.at(Cap).toStdString().c_str();

Some of the preceding assignments (ListaElementiRiga -> MyparamValuesTagliando) are OKs (I find the string I'am expecting) others KOs (strange characters).
Can someone help me?
Tk.
Please note: split is ok (all elements in ListaElementiRiga are OKs), but only some elements in MyparamValuesTagliando are OKs, others KOs).

All of your MyparamValuesTagliando[...] = ListaElementiRiga.at(...).toStdString().c_str(); statements store the result of a c_str() call against a temporary std::string and will, therefore, result in dangling pointers when those temporaries are destroyed.  So your code has undefined behaviour.

If you for some obscure reason must use raw char pointers, you need to use strdup() (note: it's a POSIX function,, so if you need fully portable C++ code, you will need to write your own implementation, basically one line of code).

G.M. and hyde, thanks for your answers.
Since G.M.'s suggestion came first, I reasoned on his indication, I made the necessary changes and now everything seems to be working.
Thank you and greetings.
