How to force show/hide + sign for numbers?

We know that ‘-‘ i.e. minus is always displayed for numbers but how about ‘+’ sign. Is there a way to show this sign using output streams in c++? The answer is yes! Use “showpos” function and use “noshowpos” to disable this functionality… [sourcecode language=’cpp’]int main() {    cout
Continue reading…

 

Replacement for CString::Format in standard C++

std::stringstream can be used as a replacement for CString::Format, if you are using CString just for the sake of Format, caveat being that it could be slow, I’ve heard a user mentioning this but not sure, I haven’t tested it out, but should be definitely better that using CString::Format and then assigning to std::string. [sourcecode […]
Continue reading…

 

Use cout to print out bool values as true and false?

Have you tried printing out bool using cout. Well who hasn’t, and most of you might have got results like 0/1. For eg: [sourcecode language=’cpp’]cout < < "1 > 2: ” < 2 );[/sourcecode] Output 1 > 2: 0 Well how to print out true or false directly instead of 0 and 1. Use boolalpha […]
Continue reading…