Reputation: 415
I have implemented the boundary fill algorithm in C language with the following code:--
/* WAP to fill the polygon using boundary fill 4 connected algo */
#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "dos.h"
void main()
{
int gd = DETECT, gm;
clrscr();
detectgraph(&gd, &gm);
initgraph(&gd, &gm , "C:\\TC\\BGI");
rectangle(60,60,500,500);
boundary_fill(65,65,4,15);
getch();
closegraph();
}
boundary_fill(int x, int y, int fclr, int bclr)
{
if(getpixel(x,y)!= bclr && getpixel(x,y)!= fclr)
{
putpixel(x,y,fclr);
boundary_fill(x+1,y,fclr,bclr);
boundary_fill(x-1,y,fclr,bclr);
boundary_fill(x,y+1,fclr,bclr);
boundary_fill(x,y-1,fclr,bclr);
}
}
when i compile it no error come. But When i run the program the window closes and i get the following error:-- C:\TC\BIN\TC.EXE The NTVDM CPU has encounterer an illegal instruction.. . . . . .
PLease help
Upvotes: 0
Views: 1123
Reputation: 25695
stop using turboC. run your 16 bit programs(such as TurboC/C++) with DosBox instead. NTVDM error occurs because of 32bit COMMAND-PROMPT trying to run a 16 Bit Program.
Upvotes: 2