0

this is a small graphical program in c....which gives you a clear discription about what a graphics can do in c..(a simple one)

// author  :: DEEPAK Ps
// amrita university ,amritapuri\
// doing bsc CS now


#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int left, top, right, bottom,i;
//   char s[20]="Done By DEEPAK..";
   /* 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 */

   }
 setbkcolor(WHITE);

  setfillstyle(XHATCH_FILL,45);
  bar(200,350,360,375);                 //   ....stand

  setcolor(BROWN);
  line(200,350,360,350);
  line(200,351,360,351);
  line(200,352,360,352);

   setfillstyle(SOLID_FILL,RED);

   bar(220,200,225,350);
   bar(220,200,300,205);    //   ..tap...
   bar(300,200,305,215);
   bar(290,180,298,200);
				     // bucket...

   bar(255,350,252,230);
   bar(335,350,338,230);
setcolor(RED);

outtextxy(10,90,"press any key to get water from the pipe...!!!");

getch();
for(i=1;i<=140;i++)
   {    setfillstyle(INTERLEAVE_FILL,BLUE);
	bar(300,210+i,305,210+i);                 //...water fill
		delay(30);
   }
   for(i=1;i<=120;i++)
   {    setfillstyle(INTERLEAVE_FILL,BLUE);
	bar(256,351-i,334,351-i);
	delay(100);                                   // bucket fill...
   }

       //     setlinestyle

   setfillstyle(SOLID_FILL,0);
	bar(300,208,310,230);
    setcolor(RED);

    setcolor(GREEN);
    outtextxy(20,110,"Bucket is full...please take your bucket..");

setcolor(BLUE);
outtextxy(50,130,"MADE BY : DEEPAK.P.S") ;
setcolor(CYAN);
outtextxy(75,150,"BSC II YEAR");



   getch();
   closegraph();
   return 0;
}
3
Contributors
2
Replies
12
Views
8 Years
Discussion Span
Last Post by Deepak_17
1

i put this code and runned.. bt its showing me error msg:
Graphics Error:Device Driver File Not Found (EGAVGA.BGI)


plz.. let me knw wats cause of error..?? expecting ur mail to me
<snip email>

thanks..

0

If you get "Graphics error : Device driver file not found <EGAVGA.BGI>" in TurboC,
you have to specify the BGI path
to the initgraph method.

For example the path "C:\TC\BGI"
and the initgraph method will be like this,

initgraph(&gdriver,&gmode,"C:\TC\BGI");

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.