1

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?

S.Mitchell
  • 91
  • 1
  • 2
  • 10
  • 3
    Probably related: [How I print UTF-8 characters C++?](http://stackoverflow.com/q/2122194), [How to print Unicode character in C++?](http://stackoverflow.com/q/12015571), [c++, cout and UTF-8](http://stackoverflow.com/q/6953847), etc. Also see [utf8 character for circle and square](https://www.google.com/search?q=utf8+character+for+circle+and+square) for the code points. – jww Nov 17 '16 at 15:16
  • 3
    `std::cout << (condition?'☐':'⚪') << std::endl;` – πάντα ῥεῖ Nov 17 '16 at 15:19

1 Answers1

2

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/

Thomas Sparber
  • 2,827
  • 2
  • 18
  • 34