1. 程式人生 > >c++將bool變量以文字形式打印

c++將bool變量以文字形式打印

true include body blog clu post down iostream ++

#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

c++將bool變量以文字形式打印