Colorful Text Output: C program

This video tutorial shows a simple method to get the output in different colors, on the dosprompt: using a simple C program.

Video Tutorial: Colorful Text Output: C program



YouTube Link: https://www.youtube.com/watch?v=TpasN_6RMMM [Watch the Video In Full Screen.]



Full Source code: Colorful Text Output: C program C

#include< stdio.h> /* Leave No space b/w < and stdio.h */void main()
{
 int i;
 clrscr();

 for( i=0; i<=15; i++ )
 {
  textcolor(i);
  cprintf("Microsoft, Google, Yahoo, Oracle, eBay, PayPal \r\n");
 }

 getch();

}

textcolor() function takes color code as it's parameter, and this color is taken by cprintf() function and the parameter(string) passed to cprintf is printed in the color given by textcolor() function.

Color Name
----------
Color code
----------
BLACK
BLUE
GREEN
CYAN
RED
MAGENTA
BROWN
LIGHTGRAY
DARKGRAY
LIGHTBLUE
LIGHTGREEN
LIGHTCYAN
LIGHTRED
LIGHTMAGENTA
YELLOW
WHITE
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

OutPut:
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal
Microsoft, Google, Yahoo, Oracle, eBay, PayPal