cout对于bool是真的(true) [英] cout true for bool(true)
问题描述
嗨
我怎么能
bool a(true);
cout<< a;
并期望打印出来
true
而不仅仅是
1
感谢
Gary Wessle写道:
< blockquote class =post_quotes>
我怎么能
bool a(true);
cout<< a;
并期望打印出来
true
而不仅仅是
1
在有人提供更便宜的答案之前,我可以问一个人是否会灌输一个
locale?
(请注意,有些文化不能称为正布尔值true;-)
-
Phlip
http://www.greencheese.us/ZeekLand < - 不是博客!!!
Gary Wessle写道:
嗨
我怎么能
bool a(true);
cout<< a;
并期望打印出来
true
而不仅仅是
1
这样的东西?
bool a = true;
std :: cout.setf(std :: ios :: boolalpha);
std :: cout<< a<< " \ n";
问候,
Sumit。
Gary Wessle写道:
嗨
我怎么能
bool a(true);
cout<< a;
并期望打印出来
true
而不仅仅是
1
将操纵者''boolapha''输出到''cout''流
输出你的布尔值之前。还要确保你
#include< iomanip> ;.
HTH,
- J.
Hi
how can I
bool a(true);
cout << a;
and expect it to print out
true
and not just
1
thanks
Gary Wessle wrote:
how can I
bool a(true);
cout << a;
and expect it to print out
true
and not just
1Before someone provides a cheaper answer, may I ask if one might imbue a
locale?
(Note that some cultures don''t call a positive boolean "true" ;-)
--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Gary Wessle wrote:Hi
how can I
bool a(true);
cout << a;
and expect it to print out
true
and not just
1
Something like this?
bool a = true;
std::cout.setf(std::ios::boolalpha);
std::cout << a << "\n";
Regards,
Sumit.
Gary Wessle wrote:Hi
how can I
bool a(true);
cout << a;
and expect it to print out
true
and not just
1Output the manipulator ''boolapha'' to the ''cout'' stream
before outputting your booleans. Also make sure you
#include <iomanip>.
HTH,
- J.
这篇关于cout对于bool是真的(true)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!