Table of Contents

graphresult

Syntax of graphresult

#include <graphics.h>
int graphresult(void);
 

Description of graphresult

graphresult returns the error code for the last graphics operation that
reported an error and resets the error level to grOk.
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
-1grNoInitGraph(BGI) graphics not installed (use initgraph)
-2grNotDetectedGraphics hardware not detected
-3grFileNotFound     Device driver file not found
-4grInvalidDriver    Invalid device driver file
-5grNoLoadMem  Not enough memory to load driver
-6grNoScanMem  Out of memory in scan fill
-7grNoFloodMem Out of memory in flood fill
-8grFontNotFound  ÂFont file not found
-9grNoFontMem  Not enough memory to load font
-10     grInvalidModeInvalid graphics mode for selected driver
-11     grErrorGraphics error
-12     grIOerror    Graphics I/O error
-13     grInvalidFontInvalid font file
-14     grInvalidFontNum   Invalid font number
-15     grInvalidDeviceNum Invalid device number
-18     grInvalidVersion   Invalid version number
Note: The variable maintained by graphresult is reset to 0 after
graphresult has been called. Therefore, you should store the value of
graphresult into a temporary variable and then test it.

Example of graphresult

/* 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;
}

See also

detectgraph drawpoly fillpoly floodfill grapherrormsg initgraph pieslice registerbgidriver registerbgifont setallpalette setcolor setfillstyle setgraphmode setlinestyle setpalette settextjustify settextstyle setusercharsize setviewport setvisualpage

output of graphresult example

  no output of example at the moment
  do not hesitate and add it...