Reputation: 3
char *pStrBuffer;
unsigned char data;
unsigned int Address;
/* pStrBuffer reading from a file data in file of the form
WriteByte(0xDE04,0x20)
WriteByte(0xFE08,0x50) ....
*/
/* in a loop */
sscanf(pStrBuffer,"%x%x",&Address,&data);
Compiler is gnu gcc 4.5 in Windows XP However the Value read for Address is 0xDE00 instead of 0xDE04 ? why is that so although value of data is read correctly. I also tried to use %lx and %hx respectively but of no use
Upvotes: 0
Views: 1707
Reputation: 400454
To read a single unsigned byte, use the %hhx
modifier. %hx
is for an unsigned short
, %x
is for an unsigned int
, %lx
is for an unsigned long
, and %llx
is for an `unsigned long long.
Upvotes: 3