先用BGIOBJ.exe 将你用的图形库(.bgi文件)编译成obj:
BGIOBJ EGAVGA.BGI
然后 需要将生成的obj文件加入到graphics.lib中去:
tlib graphics + EGAVGA.obj
上面的两步在命令提示符下完成(最好在全屏模式的command.com下完成)
最后在源代码中还需要用registerbgidriver()函数,来告诉TC编译器在连接的时候要连接BGI驱动。
这里有registerbgidriver()的源程序示例:
#include
#include
#include
#include
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
/* register a driver that was added into graphics.lib */
/* For information on adding the driver, see the
/* BGIOBJ section of UTIL.DOC */
errorcode = registerbgidriver(EGAVGA_driver);
/* report any registration errors */
if (errorcode < 0)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
/* draw a line */
line(0, 0, getmaxx(), getmaxy());
/* clean up */
getch();
closegraph();
return 0;
}
比如:
#include
void main() {
int n = 0;
printf("hello world\r\n");
scanf("%d", &n);
}
看一下hello world会不会被输出。