convert decimal to octal and hex in C with putchar() and >>
Clash Royale CLAN TAG #URR8PPP convert decimal to octal and hex in C with putchar() and >> In the example, I have this following code that can convert a decimal to binary. void show_bin(unsigned short int byte) { for (int shift=15; shift>=0; --shift) { putchar((byte>>shift)&1 ? '1' : '0'); } } How can I follow this format and write code for converting decimals to octal and hex? For example, I would like to convert 65066 to 0177052 and 0XFE2A . 65066 0177052 0XFE2A hint: >> is define as divide by 2... – Stargateur 4 mins ago >> What details is it you need help with? How many bits there are to represent an octal digit? How to make a lookup table for more than two entries? How to use printf with format specifiers to influence the representation? ...