This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

printf anomaly

I have an array

unsigned char v[4]
The 4 elements contain ASCII numerical characters that are the result of various calculations and the contents of the array is in the form: -
x.xx (in other words v[1]is always '.')
If I then use the instruction: -
printf("set_parameter %c%c%c%c\n",v[0],v[1],v[2]v[3]);
Assuming v[0] = 0x31, v[2] = 0x32 and v[3] = 0x35, I see in Hyperterminal : -
set_parameter 1.25
If, however, I use the instruction: -
printf("set_parameter %s\n",v);
I see in Hyperterminal : -
set_parameter 1.25125!£$"&*^%%$£(*
The numerical values are always repeated, the decimal point is never repeated and the extra garbage varies.

0