cooper
14th June 2011, 01:50
Hi everyone,
I am writing a program in Qt to send strings to mini panel printer through serial port.
the panel printer only accept hex code.
so, in my program, i have a function to send command to printer as follow:
ls.append(0x1B + 0x27 + 0x00 + 0x0D);
strSend(ls);
I have some parameters (int values) need to send to printer as well.
for example, i have:
int a = 3;
int b = 53;
I want to convert them to 0x03 and 0x35, and store in a_char and b_char. then i can do:
ls.append(0x1B + 0x27 + 0x00 + 0x0D + a_char + b_char);
strSend(ls);
I saw someone in this forum mentioned about itoa (a,b,16), but Qt gave me error message
error: ‘itoa’ was not declared in this scope
(I did include the stdlib.h)
Can anyone else give me a hint please?
Thanks in advance.
I am writing a program in Qt to send strings to mini panel printer through serial port.
the panel printer only accept hex code.
so, in my program, i have a function to send command to printer as follow:
ls.append(0x1B + 0x27 + 0x00 + 0x0D);
strSend(ls);
I have some parameters (int values) need to send to printer as well.
for example, i have:
int a = 3;
int b = 53;
I want to convert them to 0x03 and 0x35, and store in a_char and b_char. then i can do:
ls.append(0x1B + 0x27 + 0x00 + 0x0D + a_char + b_char);
strSend(ls);
I saw someone in this forum mentioned about itoa (a,b,16), but Qt gave me error message
error: ‘itoa’ was not declared in this scope
(I did include the stdlib.h)
Can anyone else give me a hint please?
Thanks in advance.