Hi.. I want to send Binary Data using printf() function for examle if I do
printf("%d",i)
putchar(number); putchar(number>>8);
putchar(number>>8); putchar(number);
Thanks Jhon.....It works.. But how can we send Binary Data when we have a float data type instead of integer.
"But how can we send Binary Data when we have a float data type instead of integer." You will have to read the compiler Manual to find the internal representation of the float type, and then devise a means to access the individual bytes of that representation. This is standard 'C' stuff; the main choices are: [1] shift & mask - usually portable, but often slow; [2] use a union - non-portable, but usually quicker Try a 'Search', as this has definitely been discussed before!
"printf() function transmit that integer in text mode (not in Binary mode) i.e. it will send 5 bytes for 16706" Well of course it does! The clue is in the function name: printf - clearly this is aimed at a printing output device, which will naturally expect text output! This should also serve as a warning to you: it is up to you to ensure that your entire communications link can pass binary data; it only takes one step in the link to interpret your binary data as control codes, and the entire link will get messed up. Be careful!
how can we send Binary Data when we have a float data type
. . . float x; putchar (((unsigned char *) &x) [0]); putchar (((unsigned char *) &x) [1]); putchar (((unsigned char *) &x) [2]); putchar (((unsigned char *) &x) [3]); . . .