函式原型: int fat getbkcolor(void)
基本介紹
- 外文名:getbkcolor
- 函式原型:int fat getbkcolor(void)
- 函式功能:得到當前背景顏色
- 函式返回:顏色值含義
介紹
程式例
#include<graphics.h>#include<stdlib.h>#include<string.h>#include<stdio.h>#include<conio.h>int main(void){/*request auto detection*/intgdriver=DETECT,gmode,errorcode;intbkcolor,midx,midy;char bkname[35];/*initialize graphics and local variables*/initgraph(&gdriver,&gmode,"");/*read result of initialization*/errorcode=graphresult();/*an error occurred*/if(errorcode!=grOk){printf("Graphicserror:%s\n",grapherrormsg(errorcode));printf("Press anykey to halt:");getch();/*terminate with an error code*/exit(1);}midx=getmaxx()/2;midy=getmaxy()/2;setcolor(getmaxcolor());/*for centering text on the display*/settextjustify(CENTER_TEXT,CENTER_TEXT);/*get the current background color*/bkcolor=getbkcolor();/*convert color value into a string*/itoa(bkcolor,bkname,10);strcat(bkname,"is the current background color.");/*display a message*/outtextxy(midx,midy,bkname);/*clean up*/getch();closegraph();return0;}重編者 註:itoa(bkcolor,bkname,10); 並沒有使顏色值轉換成字元串。運行結果顯示:0 is the current background color.