Turbo C Graphics - grapherrormsg 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;
detectgraph(&grd,&grm);
initgraph(&grd, &grm, "");
gresult = graphresult();
if(gresult != grOk)
{
printf(grapherrormsg(gresult));
getch();
return 0;
}
outtextxy(100,100,"softwareandfinance.com");
getch();
closegraph();
}
Output
softwareandfinance.com [in graphics screen]
|