函式功能
函式名: initgraph()
功 能: 初始化圖形系統
函式原型: void far initgraph(int far *graphdriver, int far *graphmode,
char far *pathtodriver);
頭檔案:graphics.h
程式示例
#include "graphics.h"
#include "stdio.h"
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode= graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}
/* draw a line */
line(0, 0, getmaxx(), getmaxy());
/* clean up */
getch();
closegraph();
return 0;
}