textbackground selects a new text background color
textcolor selects a new character color in text mode
Declaration:
void textbackground(int newcolor);
þvoid textcolor(int newcolor);
Remarks:
These functions work for functions that produce text-mode output directly to the screen (console output functions).
textbackground selects the background color.
textcolor selects the foreground character color.
These functions do not affect any characters currently on the screen. Once you have called one of these three functions, all subsequent functions using direct video output (such as cprintf) will use the new attributes or colors.
If you use symbolic color constants, the following limitations apply to the background colors you select:
You can only select one of the first eight colors (0--7).
NOTE: If you use the symbolic color constants, you must include CONIO.H.
NOTE: Every color name used in program you write color name upper case.
textcolor() and background() functions are declared in conio.h header file.
Blinking characters
To make the characters blink in a call to textcolor, you add 128 to theforeground color. The predefined constant BLINK exists for this purpose;for example,
textcolor(CYAN + BLINK);
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
textcolor(GREEN+BLINK);
textbackground(RED);
cprintf("Hello Friends");
getch();
}
Output:
Hello Friends
2 Comments