Created
February 19, 2019 13:23
-
-
Save boodahDEV/8461dd17b6f4338ff01feef95f2287ac to your computer and use it in GitHub Desktop.
Fuente para setear colores por línea en C, desventaja que se necesita importar la libreria "windows.h" lo cual limita en sistemas Linux.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SetColor(int ForgC){ | |
WORD wColor; | |
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | |
CONSOLE_SCREEN_BUFFER_INFO csbi; | |
if(GetConsoleScreenBufferInfo(hStdOut, &csbi)) | |
{ | |
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F); | |
SetConsoleTextAttribute(hStdOut, wColor); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Name == Value
Black == 0
Blue == 1
Green == 2
Cyan == 3
Red == 4
Magenta == 5
Brown == 6
Light Gray == 7
Dark Gray == 8
Light Blue == 9
Light Green == 10
Light Cyan == 11
Light Red == 12
Light Magenta == 13
Yellow == 14
White == 15