Is there a printf converter to print in binary format?

前端 未结 30 2762
盖世英雄少女心
盖世英雄少女心 2020-11-21 06:20

I can print with printf as a hex or octal number. Is there a format tag to print as binary, or arbitrary base?

I am running gcc.

printf(\"%d %x %o         


        
30条回答
  •  终归单人心
    2020-11-21 06:46

    There is no formatting function in the C standard library to output binary like that. All the format operations the printf family supports are towards human readable text.

提交回复
热议问题