PDA

View Full Version : cannot convert from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'char *



raed
22nd September 2011, 15:26
hi all

i have that problem
cannot convert from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'char *

i try to used Gsoup to send user name & password SP to my webservice

std::string stds;
stds=ui->lineEmail->text().toStdString() + ";"+ui->linePassword->text().toStdString();

v->param= stds; // problem in here
v->procedure="Sp_LogIn";
:mad:


can any one help me

Added after 8 minutes:

solution

QString str1 =stds.c_str();
QByteArray ba = str1.toLatin1();
char *c_str2 = ba.data();
v->param=c_str2 ;
thanks for all

franz
23rd September 2011, 07:51
This seems tricky:



QByteArray ba;
v->param = ba.data();


From the error message you gave earlier it seems v->param is of type char*. If that is true, then


{
QByteArray ba;
// ...
v->param = ba.data();
}
// v->param is a dangling pointer here


If v is only used in the same scope the byte array is used (the byte array exists as long as you use v) you should be ok though.