Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>textcolor() set the foreground color</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 textcolor()             Set the Foreground Color

 #include   <conio.h>

 void       textcolor(color);
 int        color;

    textcolor() sets the foreground text color.  The only text affected
    by a call to textcolor() is that which is displayed using direct
    console output functions after textcolor() is called.  'color' is an
    integer value from 0 to 15.

    (Color information is represented by an 8-bit value: the four lowest
    bits represent the foreground color (0-15).  The next three bits
    represent the background color(0-7).  The high bit is the blink-
    enable bit. If this bit is on, the character will blink. The symbolic
    constant BLINK is defined in <conio.h> and can be added to the
    foreground and/or background color(s) to make the character blink.
    Use textattr() to set the foreground and background colors in one
    call, and textbackground() to set the background color only.)

    The allowable colors, their symbolic constants and corresponding
    values are defined in <conio.h> :

    Symbolic constant    Value     Foreground &/or Background
     BLACK                 0            Both
     BLUE             1            Both
     GREEN                 2            Both
     CYAN             3            Both
     RED                   4            Both
     MAGENTA               5       Both
     BROWN                 6            Both
     LIGHTGRAY        7            Both
     DARKGRAY         8            Foreground
     LIGHTBLUE        9            Foreground
     LIGHTGREEN           10            Foreground
     LIGHTCYAN       11            Foreground
     LIGHTRED        12            Foreground
     LIGHTMAGENTA    13            Foreground
     YELLOW               14            Foreground
     WHITE                15            Foreground
     BLINK               128            Foreground


       Returns:     Nothing.

   Portability:     IBM PC and BIOS compatibles only.

 ------------------------------ Example ---------------------------------

    The following statements print a blinking message in yellow text on a
    green background.

           #include <conio.h>

           main()
           {

               cputs("THIS SHOWS THE ORIGINAL FOREGROUND AND BACKGROUND
                       COLORS.\n");
               textcolor(YELLOW + BLINK);
               textbackground(GREEN);
               cputs("YOU'LL SEE BLINKING YELLOW TEXT ON A GREEN
                      BACKGROUND.");
           }


See Also: textattr() textbackground()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson