是否有 printf 轉換器以二進制格式打印? - Is there a printf converter to print in binary format?

問題:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章