#include <stdio.h>
void SetColorAndBackground(int ForgC, int BackC);
void main()
{
int f,b;
system("cls");
printf("Enter fore and background color code : ");
scanf("%d",&f);
SetColorAndBackground(f,16); //color value range 0 up-to 256
printf("what is text background color");
SetColorAndBackground(30,256);
printf("\nCOLOR IN CODE BLOCKS...");
getch();
}
void SetColorAndBackground(int ForgC, int BackC)
{
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
0 comments:
Post a Comment