C语言中的grapherrormsg()函数

头文件显示图形。h包含 grapherrormsg() 返回错误消息字符串的函数。 语法:

null
char *grapherrormsg( int errorcode );
where,
errorcode: code for the respective error

图示如箭头所示: 在下面的程序中,gd=DETECT未被写入,因此程序必须抛出一个错误。

下面是C语言中grapherrormsg()函数的实现

// C Implementation for grapherrormsg()
#include <graphics.h>
#include <stdio.h>
//driver code
int main()
{
// gm is Graphics mode which is
// a computer display mode that
// generates image using pixels.
// DETECT is a macro defined in
// "graphics.h" header file
int gd, gm, errorcode;
// initgraph initializes the
// graphics system by loading a
// graphics driver from disk
initgraph(&gd, &gm, "" );
// graphresult returns the error code
// for the last graphics operation
// that reported an error and resets
// the error level to grOk.
errorcode = graphresult();
if ( errorcode != grOk)
{
printf ( "Graphics error: %s" ,
grapherrormsg(errorcode));
printf ( "Press any key to exit." );
getch();
exit (1);
}
getch();
// closegraph function closes the
// graphics mode and deallocates
// all memory allocated by
// graphics system .
closegraph();
return 0;
}


输出:

图片[1]-C语言中的grapherrormsg()函数-yiteyi-C++库
© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享