|
Description
This changes the color
of the text / background of the text
in a console window . Experiment with
different numbers for setcolor().
Useful for menus .
Code
#include <stdio.h>
#include <windows.h>
#include <conio.h>
void setcolor(unsigned short color)
{
HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hcon,color);
}
int main()
{
setcolor(1);
printf("thisll be blue\n");
setcolor(2);
printf("how about some green\n");
setcolor(5);
printf("and another color\n");
getch();
return 0;
}
Information
Tested on Visual C++
|