Proper way to use scanf with uint8_t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-29 6:58 AM
What is the best way to use sscanf with uint8_t?
When I use:
uint8_t x ;
char* y = "23" ;
sscanf ( y , "%hhu" , &x ) ;
I stuck at:
void HardFault_Handler(void)
I found following workaround that works:
uint16_t x1 ;
uint8_t x2 ;
const char* y = "23" ;
sscanf ( y , "%hu" , &x1 ) ;
x2 = (uint8_t) x1 ;
but it doesn't look best. So what is the right way of processing uint8_t in above case?
V/r
yabool2001
Solved! Go to Solution.
- Labels:
-
STM32G0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-14 12:58 PM
Likely because I'm a fossil and predominantly code to older K&R and C89 standards some of my tool chains use..
b) support only conversion specifiers defined in C89 standard. This brings us good balance between small memory footprint and full feature formatted input/output.
https://github.com/32bitmicro/newlib-nano-1.0/blob/master/newlib/README.nano#L29
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-19 9:56 AM
Thx.

- « Previous
-
- 1
- 2
- Next »