Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change text and background color?

Tags:

c++

windows

I want every character to be a different color.

for example,

cout << "Hello world" << endl;
  • H would be red
  • e would be blue
  • l would be orange and so on.

I know this can be done, I just don't know the code for it.

and I want to change the background color to white. How would I do that?

like image 658
Tprice88 Avatar asked Apr 01 '12 15:04

Tprice88


People also ask

How do I add background color to text?

How to Add Background Color in HTML. To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.

How do you change the background color and text color in HTML?

To set the background color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <body> tag, with the CSS property background-color. HTML5 do not support the <body> tag bgcolor attribute, so the CSS style is used to add background color.

How do you change the color of your text?

Open your device's Settings app . Text and display. Select Color correction. Turn on Use color correction.


1 Answers

There is no (standard) cross-platform way to do this. On windows, try using conio.h. It has the:

textcolor(); // and
textbackground();

functions.

For example:

textcolor(RED);
cprintf("H");
textcolor(BLUE);
cprintf("e");
// and so on.
like image 73
ApprenticeHacker Avatar answered Sep 30 '22 17:09

ApprenticeHacker