我尝试通过以下方法将一个QString转换为char*类型,但它们似乎都无法工作。
//QLineEdit *line=new QLineEdit();{just to describe what is line here}
QString temp=line->text();
char *str=(char *)malloc(10);
QByteArray ba=temp.toLatin1();
strcpy(str,ba.data());
能否详细说明这个方法可能存在的缺陷,或者提供一种替代方法?
QString s("some"); printf(reinterpret_cast<char *>(s.data()));
- bartolo-otrit