c++: cout将bool直接输出为true和false

//---------------------------------------
//使用boolalpha输出为bool类型
//使用noboolalpha输出为数字类型
//--------------------------------------

#include "stdafx.h"

#include 

using namespace std;

int main(int argc, char* argv[])

{

 bool test = true;

 cout << "the output is number " << test << endl;

 cout << "the output is bool(use boolalpha) " << boolalpha << test << endl;

 cout << "the output is number(use noboolalpha) " << noboolalpha << test << endl;

 system("pause");

 return 0;

}

the output is number 1

the output is bool(use boolalpha) true

the output is number(use noboolalpha) 1

请按任意键继续. . .

你可能感兴趣的:(c++学习,c++,蓝桥杯,开发语言)