SETHA SITE INFORMATION

  • Increase font size
  • Default font size
  • Decrease font size

Using window, textbackground, textcolor, gotoxy in Turbo C++

E-mail Print PDF

The below code is written in Turbo C++. It includes the uses of window, textbackground, textcolor, and gotoxy functions. There are 8 main colors in this context. (0:BLACK, 1:BLUE, 2:GREEN, 3:CYAN, 4:RED, 5:MAGENTA, 6:BROWN, 7:LIGHTGRAY)

1) Two Windows Example
#include<stdio.h>
#include<conio.h>

void main()
{
	//full screen window w: 80, h: 50
	window(1,1,80,50);
	textbackground(0);//black color
	clrscr();
	textcolor(15); //white color
	gotoxy(1,1); cprintf("WINDOW-1");

	//window 2
	window(10,10,40,20);
	textbackground(1); //blue color
	clrscr();
	textcolor(15); //white color
	gotoxy(1,1); cprintf("WINDOW-2");
	//pause screen
	getch();
}
Download Source Code Here
 
2) 8 Windows Example
#include<stdio.h>
#include<conio.h>

void main()
{
	for(int i=0; i<=7; i++)
	{
		window(1+5*i,1+3*i,80-5*i,50-3*i);
		textbackground(7-i);//black color
		clrscr();
		textcolor(i); //white color
		gotoxy(2,2); cprintf("WINDOW-%d",8-i);
	}

	//pause screen
	getch();
}
Download Source Code Here
 
3) 16 Windows Example
#include<stdio.h>
#include<conio.h>

void main()
{
	for(int i=0; i<=15; i++)
	{
		window(1+5*i,1,5+5*i,50);
		textbackground(7-i);//black color
		clrscr();
		textcolor(i); //white color
		gotoxy(2,2); cprintf("%d",i+1);
	}

	//pause screen
	getch();
}
Download Source Code Here