Home > Back-end >  Sprintf and sscanf formatting, speaking, reading and writing
Sprintf and sscanf formatting, speaking, reading and writing

Time:09-22


U8 type=1;
U8 rssi=100;
U8 tag=1;
U8 addr [6]={x58 x56 0, 0 x57, 0, 0 x00 to 0 x00 to 0 x00};
Double x=100.2;
Double y=102.5;
U8 payload1 [40].
Sprintf (payload1 (char *), "% % % c, 6 x, lf, lf, % % c % c", the type, addr, x, y, rssi, the tag);


U8 temp.
U8 type=0;
U8 rssi=0;
U8 addr2 [6].
Double x;
Double y;
U8 tag;
Printf ((const char *) content;
printf("\n");
Sscanf ((const char *) content, "% % % c, 6 x, lf, lf, % % c % c", & amp; Type, addr2 addr, & amp; X, & amp; Y, & amp; Rssi, & amp; The tag);

Is stored in payload1 during the process of reading and writing is not addr the values in the array, but addr pointer address, is this why?
I want to write the value is used in addr payload1, next reoccupy sscanf formatting wrote addr2, should how to write?
There's just one problem: I will % 6 x as % s payload1 addr content in the subscript upside down, why?

CodePudding user response:

Has been solved,,,,,,,,