You are here

grapherrormsg function in C

grapherrormsg function returns an error message string.

Declaration: char *grapherrormsg( int errorcode );

C programming code for grapherrormsg

  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4.  
  5. main()
  6. {
  7.    int gd, gm, errorcode;
  8.  
  9.    initgraph(&gd, &gm, "C:\\TC\\BGI");
  10.  
  11.    errorcode = graphresult();
  12.  
  13.    if(errorcode != grOk)
  14.    {
  15.       printf("Graphics error: %s\n", grapherrormsg(errorcode));
  16.       printf("Press any key to exit.");
  17.       getch();
  18.       exit(1);
  19.    }
  20.  
  21.    getch();
  22.    closegraph();
  23.    return 0;
  24. }

In the above program we have not written gd = DETECT.
After running this program we get the output :-
Graphics error: Graphics hardware not detected
Press any key to exit.