Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to convert qstring into char array
How to convert qstring into char array
Qstring to char array:

QString str = " 12 fff ";

QByteArray ba = str . tolatin 1();

char * c = ba . data();

Analysis:

To Latin 1QString to QByteArray method, Latin 1 stands for ASCII.

Const char*: a pointer to a character constant.

const? Charles? *? ss=? “XXXXXX”;

Indicates that what the pointer points to cannot be modified.

Charles? *? const? ss? =? “XXXXXX”; ?

Explain that this is a pointer constant and cannot point to other addresses, such as ss=? ... is not allowed.

const? Charles? *? const? ss? =""? ; ?

The pointer cannot be modified, nor can the content it points to be modified.

Extended data:

Char array converted to QString:

char c[]= " 12ff ";

QString str = QString(qlatin 1 string(c));

For strings:

/0 means terminator, for example, in an array added by C language, there is a default /0 at the end.

/0 is not a space,'' is a space.

Is an empty string.