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
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
View Comments
Discussion Thread Forum: https://technotip.com/forums/topic/printing-the-text-with-color-in-c/#post-989