You are here

getbkcolor function in c

getbkcolor function returns the current background color

Declaration : int getbkcolor();

e.g. color = getbkcolor(); // color is an int variable
if current background color is GREEN then color will be 2.

C program for getbkcolor

  1. #include<graphics.h>
  2. #include<conio.h>
  3.  
  4. main()
  5. {
  6.    int gd = DETECT, gm, bkcolor;
  7.    char a[100];
  8.  
  9.    initgraph(&gd,&gm,"C:\\TC\\BGI");
  10.    
  11.    bkcolor = getbkcolor();
  12.  
  13.    sprintf(a,"Current background color = %d", bkcolor);
  14.    outtextxy( 10, 10, a);
  15.  
  16.    getch();
  17.    closegraph();
  18.    return 0;
  19. }