How do I print one bit?

后端 未结 6 402
野性不改
野性不改 2021-01-18 04:30

Please tell me how do I print a bit, like printf(\"%d\",bit);.

6条回答
  •  伪装坚强ぢ
    2021-01-18 05:03

    The C++ answer is easier than the C89 one, with the native bool type:

    bool b = true;
    std::cout << b;
    

    C99 is quite similar:

    _Bool b = 1;
    printf("%d", b);
    

提交回复
热议问题