Apr 02, 2012 I want every character to be a different color. For example, cout change the background color to white. How would I do that?
![]()
Through the standard, no. The screen doesn't even exist in C++, so neither do colors. Purely text and a standard input and output, and they're not even defined as to what it has to be.
However, there is several possibilities. If you're on windows, you can call the batch command 'color' using the system function. This will effectively change the background and foreground for the console until it's closed or changed again. You can use an API specific version, there is some code here and on other sites that allow you to change color per character on the console. I have one that works with Windows, other operating systems not so much. There is the option of going the ANSI route. Again, not standard, and not even guaranteed to work on all three of the main OS's. It is, however, going to work on the widest variety of computers, but isn't guaranteed to work on any. It's up to you to pick what you want, and it's up to you to decide if you really want to implement it into your code. Again, it's not standard, and consoles aren't meant to use colors, however, some people swear it's what they want/need. Background Color Images
How To Change The Background Color Of Output Screen In Dev C++Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |