問題:
I can print with printf
as a hex or octal number.我可以用printf
打印爲十六進制或八進制數。 Is there a format tag to print as binary, or arbitrary base?是否有以二進制或任意基數打印的格式標籤?
I am running gcc.我正在運行 gcc。
printf("%d %x %o\n", 10, 10, 10); //prints "10 A 12\n"
print("%b\n", 10); // prints "%b\n"
解決方案:
參考一: https://en.stackoom.com/question/T7I參考二: https://stackoom.com/question/T7I