How to use Colors in C Language

  • Program to demonstrate each color (text, background) in C Language.
  • <conio.h> header files contains the color related library function, it also contains the name constant to BLINK text.
  • Text Color, Text Background and color and BLINK option is demonstrated here.
#include <conio.h>
void main(void)
{
   int i;
   clrscr();
   textcolor(5+BLINK);
   printf("COLOR DEMO \n\n");
   for (i=0; i<16; i++)
   {
       textcolor(i);
       if (i==0)
		textbackground(WHITE);
       else
		textbackground(BLACK);
       cprintf("Color code -> %d",i);
       //cprintf("\r\n");
	printf("\n");

   }
   getch();
}

Leave a Comment