cmd run the program to change the font and background (c ++) (windows)

In #include <windows.h> Curry

First to know:

0 = black
1 = blue
2 = green
3 = blue lake
4 = red
5 = purple
6 = Yellow
7 = White
8 = Gray
9 = light blue
A = light green
B = light green light
C = pink
D = lavender
E = light yellow
F = bright white
 
method one:
On the Standard cmd color function ( note change all !!! )
#include <bits / STDC ++ H.> 
#include <WINDOWS.H> 
the using namespace STD; 

int main () { 
	System ( "Color 46 is"); // The first is the background, is the second font 
     // This is red and yellow return 0; }

Method Two:

Use SetConsoleTextAttribute  ( Baidu translation: a collection of console text attributes )

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;

int main() {
	for (int i=0;i<8192;i++)
	{
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),i);
		printf("%x\n",i);
	}
	return 0;
}
 
According to the above experiment known: Hex follows:
The first: Fonts
Second place: Background
Third: No 0-3
    Streaked onto 4-7 (the same color and font)
    8 ~ b left vertical line (the same color and font)
    c ~ f the upper left line (the same color and font)
    10 to 13, the right vertical (the same color and font)
    17 line 14 to the upper right (the same color and font)
    18 - around the line 1b (the same color and font)
    1c ~ 1f about on-line (the same color and font)
Use of the above, to make the program look better! ! !
 

Guess you like

Origin www.cnblogs.com/Srand-X/p/12122045.html