Can someone give me a piece of code that changes the background and text colour or each individually?
You can change this in the registry under HKEY_CURRENT_USER\\Console\\ScreenColors
It's a REG_DWORD which is 0xa by default (white on black).
Otherwise you could try:
1 2 3 4 5 6 7 8 9 10 11
|
#include <windows.h>
#include <iostream>
int main()
{
for (int color = 1; color < 255; ++color)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
std::cout << "Color: " << color << std::endl;
std::cin.get();
}
}
|
where setting color to:
10 = green on black
11 = cyan on black
12 = red on black
13 = Magenta on black
14 = yellow on black
15 = white on black
Edit: I skipped color = 0 because it's black on black (a little strange if you run this for the first time without knowing what's going to happen);
Last edited on
Thank's :D Can I ask what cin.get(); does? I've seen it a few times when people are changing text colour
Most people use it to wait for the user to hit the enter/return key