博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
boolalpha的用法和作用
阅读量:7015 次
发布时间:2019-06-28

本文共 457 字,大约阅读时间需要 1 分钟。

#include 
using namespace std;int main(){ bool b=true; cout << "b=" << b << endl; b = false; cout << "b=" << b << endl; cout << "b=" << boolalpha << b << endl; cout << b << endl; bool a = true; cout << "a = " << a << endl;}

输出结果:

b=1b=0b=falsefalsea = true

可见boolalpha的作用是使bool型变量按照false、true的格式输出。如不使用该标识符,那么结果会按照1、0的格式输出。这个setw等格式化输出类似。

转载于:https://www.cnblogs.com/wlzy/p/6986419.html

你可能感兴趣的文章