Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 11-04-2008, 09:39 AM   #1 (permalink)
Indidiot
 
Plasma_Snake's Avatar
 
Join Date: Dec 2007
Location: Rock Island
Posts: 1,416
Default Debug the DDA


Below the is the program code for DDA line drawing algorithm. It compiles with no error and runs fine on my college computers but at my home it gives "run time error" which is"BGI Error: Graphics not initialized(use 'initgraph')". Resolve it please.

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd,gm,x1,x2,y1,y2,xinc,yinc,i,dx,dy,len,x,y;
gd = DETECT;
initgraph(&gd,&gm," ");
printf("enter the coordinates of x1,y1 and x2,y2 ");
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
dx = ( x2-x1 );
dy = ( y2-y1 );
if( dx > dy )
len = abs(dx);
else
len = abs(dy);
xinc = dx/len;
yinc = dy/len;
x = x1;
y = y1;
for(i=1;i<=len;i++)
{ x = x+xinc;
y = y+yinc;
putpixel(x,y,3);
}
getch();
}
Plasma_Snake is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 11-04-2008, 09:57 AM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: Debug the DDA

I don't know BGI etc but shouldn't your gm variable be initialized before address-passing to initgraph() ?
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 11-04-2008, 10:03 AM   #3 (permalink)
PhotonAttack
 
DigitalDude's Avatar
 
Join Date: Oct 2007
Location: Chennai
Posts: 1,277
Default Re: Debug the DDA

Bgi Error: Graphics not initialized (use initgraph)


_
__________________
In a time of universal deceit, telling the truth is a revolutionary act - George Orwell

|| तमसो मा ज्योतिर्गमय ||
DigitalDude is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please debug this C program!!! ajaybc Programming 15 05-04-2008 12:07 AM
can anyone debug this cpp prog pls bharat_r Programming 6 22-10-2007 11:36 PM
Can't debug ComputerUser Software Q&A 5 20-09-2007 05:50 PM
Bug, Blog & Debug The Incredible QnA (read only) 8 02-06-2005 05:22 PM

 
Latest Threads
- by Sujeet
- by clmlbx
- by Sujeet
- by icebags

Advertisement




All times are GMT +5.5. The time now is 10:57 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2