I am having a project using C (the compiler I think I am using is Turbo C++ 3.0). I used some textcolor()
and textbackground()
functions to color some text. When I run it the first time, the console is in its normal colors—white text on black background.
However, when I run the code for the second time and so on, the background color becomes blue.
I used the following code for the above program (the only formatted text using cprintf()
were the text in magenta and blue backgrounds):
...
gotoxy(10, 19);
textcolor(LIGHTCYAN);
textbackground(MAGENTA);
cprintf(" A "); printf(" ");
cprintf(" F "); printf(" ");
cprintf(" G "); printf(" ");
cprintf(" K "); printf(" ");
cprintf(" Z "); printf(" ");
cprintf(" E "); printf(" ");
cprintf(" I "); printf(" ");
...
I suspect this is because of the compiler I am using but I am still not sure. Is there any way to solve this?
After you are done drawing the letters you want to have MAGENTA background you should reset the background color back to BLACK:
textbackground(BLACK);