How to change text color and text background in Turbo C/C++ without using graphics

<marquee>Text and background color in turbo C++/C</marquee>


Everyone wants to create a good looking and attractive..
Using graphics for small programs is very clumsy, time consuming and a bit hard task to do..
So is there any other way???
Yes!!! there is !!!
And today i will teach you how to change text color and text background in Turbo C/C++
without using any graphics...
Before that if you don't have Turbo C/C++, then download one from here for win xp/7/8/8.1

Header file required is conio.hWe are going to use two functions
1. textcolor() : for changing color of text
2. textbackground() : for changing the background
supported colors are
BLACK, WHITE, RED, BLUE, BROWN, YELLOW, PINK, CYAN etc
it is necessary to write them in capital....
use them as follows:
textcolor(RED) :To change text color to red
textcolor(RED+BLINK) : to add blink efffect
similarly
textbackground(WHITE) : to change background to white


sample code:

#include<conio.h>

int main(void)
{
   int i, j;

   clrscr();
   for (i=0; i<9; i++)
   {
       for (j=0; j<80; j++)
 cprintf("C");
       cprintf("\r\n");
       textcolor(i+1);
       textbackground(i);
   }

   return 0;
   getch();
}




Output:






Popular posts from this blog

[How to] install Remastersys on Unbuntu 14.04 [Linux] with GUI support

RTU B.Tech 4th semester Computer science Syllabus (Common to IT also)

[How to] Connect an android device [using MTP] on Linux [Ubuntu 14.04 LTS] 100% working