TITLE: stream output of "true" and "false" for bools (Source: comp.lang.c++.moderated, 27 Sep 2000) SCHWARTZ: notbob_schwartz@my-deja.com > #include KUEHL: Dietmar Kuehl This is a non-standard header. The corresponding standard header is called . This puts basically all names into the namespace 'std'. Thus, a corrected version of your program reads #include int main() { std::cout << true << '\n'; std::cout << false << '\n'; } You also don't want to write 'std::endl' instead of '\n' because the use of 'std::endl' would unnecessarily flush the stream's buffer. This is a bad idea unless you really want to play save and have the buffer flushed: Flushing the buffer can become a considerable performance problem. SCHWARTZ: > and yields the following output: > > 1 > 0 KUEHL: Which is the correct output: By default, this is the only correct output. If you want... SCHWARTZ: > true > false KUEHL: you have to set 'std::ios_base::boolalpha' and use an English locale (the default locale is such a locale): std::cout << std::boolalpha << true << '\n'; The manipulator 'std::boolalpha' just sets the flag, ie. you can achieve the same result using std::cout.setf(std::ios_base::boolalpha); std::cout << true << '\n'; ... and you can install a modified 'std::numpunct' facet into the used locale object to get eg. the German equivalents: #include #include class german_numpunct: public std::numpunct { string_type do_truename() const { return "wahr"; } string_type do_falsename() const { return "falsch"; } }; int main() { std::locale loc; std::locale german_loc(loc, new german_numpunct); std::cout.imbue(german_loc); std::cout << std::boolalpha << true << ' ' << false << '\n'; } [snip] _______________________________________________ cpptips mailing list http://cpptips.hyperformix.com