c++ - Pushing a QChar in QString -


#include <qcoreapplication> #include <qdebug>  int main(int argc, char *argv[]) {     qcoreapplication (argc, argv);      unsigned char vel_left = 0;     vel_left  = vel_left | 100;      qstring packet;     packet.push_back (qchar (vel_left));      qdebug () << "vel_left: " << vel_left;     qdebug () << "packet: " << packet;      return a.exec(); } 

the intention here manipulate 8 bits oring or anding them, , storing them in string.

then read output decimal.

output of program is:

val_left: 100 packet: "d" 

what "d" here?

100 way machine encodes lower case d character. so

char x = 'd'; 

is same as

char x = 100; 

you may confusing numbers representations. 1 hundred number. can represented string "100" or hundred cars or sentence "one more ninety-nine'. same number represented.

"100" representation. in base 10 represents number 1 hundred. in other representation systems, can represent other numbers.

you made string store number 1 hundred. printed using system's character representation. well, system uses number on hundred represent character "d".

what want string store? number 1 hundred? characters "1", "0", "0"? or what?


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -