Can I use a binary literal in C or C++?

前端 未结 19 2444
梦如初夏
梦如初夏 2020-11-22 07:40

I need to work with a binary number.

I tried writing:

const x = 00010000;

But it didn\'t work.

I know that I can use an hex

19条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 08:02

    You can use a bitset

    bitset<8> b(string("00010000"));
    int i = (int)(bs.to_ulong());
    cout<

提交回复
热议问题