Me facing problems with Graphics related programs...
Even though I have everything properly installed,it shows the error that Graphics not initialized ..
here is a sample program DDA Line Algo...
I get an error saying
damn iam using initgraph in this but then also it shows me the same problem...


Even though I have everything properly installed,it shows the error that Graphics not initialized ..

here is a sample program DDA Line Algo...

Code:
#include<stdio.h>
#include<graphics.h>
#include<math.h>
void main()
{
float x,y,x1,y1,x2,y2,dx,dy,length;
int i,gd=DETECT,gm;
clrscr();
printf("Enter the value of x1,y1: ");
scanf("%f %f",&x1,&y1);
printf("Enter the value of x2,y2: ");
scanf("%f %f",&x2,&y2);
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\tc\bgi\egavga.bgi");
dx=abs(x2-x1);
dy=abs(y2-y1);
if (dx >= dy)
{ length = dx;
}
else
{ length = dy;
}
dx = (x2-x1)/length;
dy = (y2-y1)/length;
x = x1 + 0.5;
y = y1 + 0.5;
i = 1;
while(i <= length)
{ putpixel(x,y,15);
x = x + dx;
y = y + dy;
i++;
delay(100); }
getch();
closegraph();
}
I get an error saying
Code:
BGI ERROR: Graphics not initialised (use 'initgraph')

