M
Magix
Hi,
I want to manipulate an incoming WORD as I receive byte by byte. let say 07
D4, which is 2004
I want to combine these two bytes and convert into decimal, then convert as
a string. (sprintf)
int MSB;
int LSB;
int Total;
char buf[5];
MSB = (0x07 << 8)
LSB= (0xD4 & 0x00FF)
Total = MSB | LSB
sprintf(buf, "%d",Total);
When I print buf in %s format, the output I expected is 2004. But it prints
"-long printf)d"
What is wrong in my code above ?
Thanks.
I want to manipulate an incoming WORD as I receive byte by byte. let say 07
D4, which is 2004
I want to combine these two bytes and convert into decimal, then convert as
a string. (sprintf)
int MSB;
int LSB;
int Total;
char buf[5];
MSB = (0x07 << 8)
LSB= (0xD4 & 0x00FF)
Total = MSB | LSB
sprintf(buf, "%d",Total);
When I print buf in %s format, the output I expected is 2004. But it prints
"-long printf)d"
What is wrong in my code above ?
Thanks.