#include <graphics.h> int graphresult(void);
The following table lists the error codes returned by graphresult. The enumerated type graph_errors defines the errors in this table. graph_errors is declared in graphics.h.
| code | constant | Corresponding error message string
| 0 | grOk | No error
| -1 | grNoInitGraph | (BGI) graphics not installed (use initgraph)
| -2 | grNotDetected | Graphics hardware not detected
| -3 | grFileNotFound | Device driver file not found
| -4 | grInvalidDriver | Invalid device driver file
| -5 | grNoLoadMem | Not enough memory to load driver
| -6 | grNoScanMem | Out of memory in scan fill
| -7 | grNoFloodMem | Out of memory in flood fill
| -8 | grFontNotFound | Font file not found
| -9 | grNoFontMem | Not enough memory to load font
| -10 | grInvalidMode | Invalid graphics mode for selected driver
| -11 | grError | Graphics error
| -12 | grIOerror | Graphics I/O error
| -13 | grInvalidFont | Invalid font file
| -14 | grInvalidFontNum | Invalid font number
| -15 | grInvalidDeviceNum | Invalid device number
| -18 | grInvalidVersion | Invalid version number
| |
/* graphresult example */
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics and local variables */
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); /* terminate with an error code */
}
/* draw a line */
line(0, 0, getmaxx(), getmaxy());
/* clean up */
getch();
closegraph();
return 0;
}