The textbackground() function is defined in the conio.h header file. This function helps to change the background colour of printed text.
void textbackground(int color); #Where color is a integer variable
The textbackground() function takes a single parameter 'color' it is a integer variable which holds the corresponding integer value of a given colour.
Parameter | Description | Required / Optional |
---|---|---|
color | it has a integer value | Required |
The textbackground() function does not return any value it just change the text background.
#include <stdio.h>
#include <conio.h>
int main()
{
// setting the background color of text
textbackground(GREEN);
cprintf("Change the text background colour to green");
getch();
return 0;
}
Output:
Change the text background colour to green /* with green background colour */
#include <stdio.h>
#include <conio.h>
int main()
{
textbackground(RED);
cprintf("and the answer is 42 with a red background.");
getch();
return 0;
}
Output:
and the answer is 42 with a red background