adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Text & background color in C language

              textbackground selects a new text background color
              textcolor selects a new character color in text mode

              Declaration:
                   void textbackground(int newcolor);
                   Ã¾void textcolor(int newcolor);
       

Remarks:

                  These functions work for functions that produce text-mode output directly to the screen (console output functions).
      
     textbackground selects the background color.
     textcolor selects the foreground character color.

These functions do not affect any characters currently on the screen. Once you have called one of these three functions, all subsequent functions using direct video output (such as cprintf) will use the new attributes or colors.

If you use symbolic color constants, the following limitations apply to the background colors you select:
   You can only select one of the first eight colors (0--7).
 NOTE: If you use the symbolic color constants, you must include CONIO.H.
 NOTE: Every color name used in program you write color name upper case.
              textcolor() and background() functions are declared in conio.h header file.


 Blinking characters

  To make the characters blink in a call to textcolor, you add 128 to theforeground color. The predefined constant BLINK exists for this purpose;for example,
        
               textcolor(CYAN + BLINK);
  

 Program:

 #include<stdio.h>
 #include<conio.h>
 void main()
   {
    clrscr();
    textcolor(GREEN+BLINK);
    textbackground(RED);
    cprintf("Hello Friends");
    getch();
    }

  Output: 

    Hello Friends

   You can see above program in video


Post a Comment

2 Comments

williams said…
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "https://codeprozone.com/code/cpp/32877/c-change-console-color.html" answered properly. Developers are finding an appropriate answer about c++ change console color related to the C++ coding language.
Anonymous said…
Really best Website