c++将bool变量以文字形式打印

#include <iostream>     // std::cout, std::boolalpha, std::noboolalpha

int main () {
      bool b = true;
      std::cout << std::boolalpha;
      std::cout << b << std::endl;
      std::cout << false << std::endl;
      std::cout << std::noboolalpha;
      std::cout << b << std::endl;
      std::cout << false << std::endl;
}

输出结果:

true
false
1
0
posted @ 2018-01-11 10:08  catmelo  阅读(1664)  评论(0编辑  收藏  举报