Source code in embedded C for unsigned integer to string
问题 Without resorting to standard library utoa, I'm looking for source code of utoa so I may customise it for specific project. I have unsigned integer (32 bits) with output such as 0xFFFF_FFFF I also looking for source code for unsigned integer and half word to string in binary format. 回答1: Try this: char *dec(unsigned x, char *s) { *--s = 0; if (!x) *--s = '0'; for (; x; x/=10) *--s = '0'+x%10; return s; } You call it with a pointer to the end of a caller-provided buffer, and the function