我正在尝试在graphics
系统上运行Ubuntu 18.04 LTS
程序以打印error code
,以防止图形操作失败。我的代码是
#include <graphics.h>
#include <stdlib.h>
int main()
{
int gd,gm,errorcode;
initgraph(&gd,&gm,NULL);
errorcode = graphresult();
if(errorcode != grOk)
{
printf("Graphics error: %s\n",grapherrormsg(errorcode));
printf("Press any key to exit.");
getch();
exit(1);
}
getch();
closegraph();
return 0;
}
但是当我运行它时,出现以下错误:
g++ -o mygraphics mygraphics.c -lgraph
mygraphics.c: In function ‘int main()’:
mygraphics.c:10:20: error: ‘graphresult’ was not declared in this scope
errorcode = graphresult();
^~~~~~~~~~~
mygraphics.c:12:24: error: ‘grOk’ was not declared in this scope
if(errorcode != grOk)
^~~~
mygraphics.c:12:24: note: suggested alternative: ‘brk’
if(errorcode != grOk)
^~~~
brk
mygraphics.c:14:42: error: ‘grapherrormsg’ was not declared in this scope
printf("Graphics error: %s\n",grapherrormsg(errorcode));
我在互联网上进行了搜索,但找不到有希望的解决方案。有人可以帮我吗。预先谢谢你:)