answersLogoWhite

0


Best Answer

There is no generic C++ code for changing background colours as consoles are platform-specific. In Windows, for instance, you would use the SetConsoleTextAttribute function. The following code demonstrates how it works:

#include<iostream>

#include<Windows.h>

int main()

{

for(int colour=0x00; colour<=0xff; ++colour)

{

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),colour);

std::cout<<"Using colour:"<<colour<<std::endl;

}

return(0);

}

Note that the least-significant nybble (4-bits or a half byte) changes the foreground colour, while the most-significant nybble changes the background colour.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Code for changing background color in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why is the background screen of c plus plus blue?

It has to be some color and blue is nice.


How do you make a background on stardoll presentation without word or firefox?

Any Web Browser is available for your Presentation. Not using Firefox just limits you of Flashing Text and some Multiple Borders.You are able to use HTML Codes (preferred) or different coding for your background and multiple effects. Plus, you can drag Backgrounds from different users on Stardoll, which I suggest you to create your own preferred background. I include you the HTML Code for Backgrounds with Text Alignment, Font, Font Size, Font Color and Text Shadow included. For different colors you can use to modify your background code I included 'Computer Hope: HTML Color Codes and Names.'Background Code:Background HTML CodeIf you just want the background code you can just use:Background HTML CodeYou edit the color of the Background, deleting "8B0000" for "red" or other colors listed on the page I included before. You write on the "Background HTML Code" with other text of your choice. If you need more information about HTML Codes you can contact me on my Message Board.Answered by Megajessica225 add me :) and heart my yb


Why the background colour of turbo c plus plus is blue?

I want my C++ program become interesting How can I change the color of background and color of font even size of font......... I will always use system("cls") to clear there screen..... so I want do C++ DOS into something we call presentation like powerpoint Haha........ Any tutorial? That all Thank you


What is the color you see if the color is red plus blue plus green?

A brownish color.


Where on windows live messenger how do you make a coloured display name?

A button called "Format Codes" is beside the spot where you enter the name. If it's not there, you might need to get Messenger Plus! Live.[c=4]Your Name[/c] will make it red. Different numbers after the = sign will make other colors. If it still does not work after entering that, then you need Messenger Plus! Live.


Which mobile company code is plus plus 372?

Its code of estonia


Plus 621 is for which country code?

plus 621 what country code


Resistor color code 120 k ohm resistance plus or minus deviation?

brown, red, yellow , in case of gold its 5% tolerence, silver 10% tolerence, no color 20% tolence..


Acceleration is how fast a velocity is changing at a specific instant?

Yes, plus the direction that it's changing in.


What is reading plus site code?

A "site code" for reading plus is a code usually given to you by your teacher. Everyone in your school uses this code. You will have to use this the first time you sign in on reading plus.


What color does green plus yellow plus red make?

it makes an ugly color of brown


What color does yellow plus green plus red make?

it makes an ugly color of brown