• Have Any Question?
  • contact@eitworld.com

Grapherrormsg() Function





grapherrormsg() return an error message or string. When you call the initgraph() function of graphics.h header file a function graphresult() provides an errorcode and that errorcode is accepted by the grapherrormsg() function and after accepting that errorcode grapherrormsg() fuction returns an error string.

Declaration

char *grapherrormsg( int errorcode );
  • grapherrormsg() function contains only one argument that is errorcode which would be generated by the graphresult() fuction.
  • grapherrormsg returns a pointer to an error message string.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm,errorcode;

char a[50];

initgraph(&gd,&gm,” “);

errorcode=graphresult();

if(errorcode!=grOk)

{

sprintf(a,”Graphics error:%s”,(grapherrormsg(errorcode)));

outtexttexy(100,240,a);

getch();

return 0;

}

circle(320,240,100);

getch();

closegraph();

}

Above program will display an error message if there will any error. 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: Graphics error:device drive file not fornd (EGAVGA.BGI). If there is no error then it will display a circle of 100 cm radius at position(320,240) as given below:

Output

c graphics



Real Time Web Analytics