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;
}

輸出結果:ios

true
false
1
0
相關文章
相關標籤/搜索