• Have Any Question?
  • contact@eitworld.com

Getbkcolor() Function





getbkcolor() returns the current background color.getbkcolor()returns the current background color.

int getbkcolor();
  • getbkcolor(); returns an integer value. This integer value is a value associated with the current background color. Default background color is black and the value associated with black color is 0.
  • There are various colors that are also mentioned in graphics.h header file and the possible color values are from 0 – 15:BLACK(0), BLUE(1), GREEN(2), CYAN(3), RED(4), MAGENTA(5), BROWN(6), LIGHTGRAY(7), DARKGRAY(8), LIGHTBLUE(9), LIGHTGREEN(10), LIGHTCYAN(11), LIGHTRED(12), LIGHTMAGENTA(13), YELLOW(14), WHITE(15).
  • You can also set the background color of your choice by setbkcolor() function.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm,bkcolor;

char a[50];

initgraph(&gd,&gm,” “);

bkcolor=getbkcolor();

sprintf(a,”The value of the current background color is %d”,bkcolor);

outtextxy(100,240,a);

getch();

closegraph();

}

Above program will get the current background color with the help of getbkcolor() function. This returns the value associated with the current background and stores in the integer variable bkcolor. The default background color is black and value associated with black color is 0 so it stores the 0 in bkcolor. Then the program will display a message as given in the output.

Output

getbkcolor



Real Time Web Analytics