PDA

View Full Version : Problem in storing hex data to char variable



prasad1001
7th April 2014, 07:07
Hi to all,
I am new to Qt, i am writing code to convert integer to hex value and to store it in a char variable. I am converting int to hex value, but am facing problem in storing the resultant value to a char variable.

My code is..


int id=20;
QString sid=QString::number(id,16);

But I want to store the hex value to char variable not QString or char* or char array...
Please help me..
Thanks in advance..

ChrisW67
7th April 2014, 08:16
You can't in general. Any value greater than 15 you give QString::number() will convert to two or more characters. Obviously that cannot fit in a single char variable.