问题:
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