-3

I have been using turbo c++ from quite long time, I have noticed that there are by default 16 colours(0-15) but I know that there is a way to make your own custom background and text colours, does anybody know how to do it...?

Angad Singh
  • 1,032
  • 1
  • 17
  • 36

3 Answers3

1

In text mode there truly are only 16 colors each for foreground and background, because foreground and background color are each specified by a four bit bitfield, so that the total is 8 bits, and it's stored in video RAM just like that and interpreted by the GPU (in VESA emulation mode).

To get additional colors, you'll have to switch to a graphics mode. You may want to search for "Turbo C++ graphic mode", which finds many tutorials.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
0

In Turbo C++ you can use textcolor( ) textbackground( ) to set whatever color you want out of the color palette. Browse the Help menu.

// MSDOS Turbo C++ code
#include <conio.h> 


    int main() 
    { 

        textbackground(BLUE); //set the background color 
        textcolor(WHITE); 
        clrscr();
        gotoxy(30,12); 
        cputs("Hello"); 


    return 0; 
    }
Software_Designer
  • 8,490
  • 3
  • 24
  • 28
  • That doesn't solve the problem, I know that there are 16 macros/enumerator for default colour,but I want more than 16 colours. – Angad Singh May 30 '15 at 21:07
-1

You can use more colors using graphics by using setrgbpalette() function... To know more about this function see setrgbpalette in the help index (or here) and compile the given example of setrgbpalette. You can create more custom colors, but only 16 colors can be used at a time.

jcoppens
  • 5,306
  • 6
  • 27
  • 47