Software & Finance

Turbo C Graphics - graphresult function

graphresult is function is used to get the errorcode after you made a call to initgraph function. grapherrormsg will accept the errorcode and returns the error string.


initgraph function is used to initialize with the graphics library and changes to the graphics screen for drawing. It is the first step you need to do during graphics programming. The sample code is given below on this page.


To get an error, delete the *.BGI file in your local folder or remove BGI directory from your path settings: Then you will get the error string: device drive file not found (EGAVGA.BGI)



Back to Turbo C Graphics Index

Source Code

#include <graphics.h>

#include <stdio.h>

#include <math.h>

#include <conio.h>

#include <dos.h>

#include <stdlib.h>


void main()


      int i, grd, grm;

      int x, y, w, gresult;


      initgraph(&grd, &grm, "");


      gresult = graphresult();

      if(gresult != grOk)




              return 0;







Output [in graphics screen]