Problem With Text Color Function In TURBO C++

closed account (y6q2y60M)
Please Help Me!!!

I Have this code which should print the output in color but thats not happening.
please help

[code]

code.......

int myarray[] = { 100, 200, 300, 400, 500 };

for(i=0; ch!=27 ; )
{




ch=getch();
if(ch==80)
{
i++;

clrscr();

for (int j = 0; j < 5; ++j)
{
if (j == i)
{
textcolor(15);
cprintf("\n", myarray[j] );
// it should print the elements of myarray in color but it is not. :(
}
else
{
textcolor(7);
cprintf("\n", myarray[j]);
}
}

code.............
Last edited on
try this :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int main(){
	int i;
	int ch = -1;
	int myarray[] = { 100, 200, 300, 400, 500 };

	for(i=0; ch!=27 ; )
	{

		ch=getch();
		if(ch==80)
		{
			system("cls"); 
			cprintf("\n %u" ,myarray[i ++]);
			if(i % 2 == 0)
				system("color 15");
			else
				system("color 7");

			

		}
	}
		system("pause");
        return 0;
Last edited on
@Ericool
That doesn't do what you think it does, and it doesn't answer the OP's problem. Sorry.

@prankster
You are using Turbo C++, right? What version? (4.0 or better?)
What OS are using?
What is the value of the directvideo variable?

If playing with the directvideo variable doesn't help, you might have to run you program with DosBox -- which emulates the old 16-bit console environment.
http://www.dosbox.com/
Topic archived. No new replies allowed.