S.Mitchell S.Mitchell - 1 year ago 80
C++ Question

formatting output of booleans c++

I am a begginner at programming in c++ and I would like to know if there is a way you can change the output of boolean variables to low level graphics in the terminal (linux). To Display for example a small circle for true and a small square for false.

I am needing to display an array of booleans in terms of small symbols such as the example above as the output for a project, any suggestions on the best way to impliment this function if what I have asked is not possible?

Answer Source

You can print unicode Symbols using std::wcout. E.g. "\u2605" will print a star.

So you can write something like

std::wcout<< (myBool) ? "\u2605" : "\u25CF" <<std::endl;

This will print a star if myBool is true or a circle if false

You can find many tables of Unicode characters online, e.g. here: http://jrgraphix.net/r/Unicode/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download