我已经实现了在C语言中的边界填充算法用下面的代码: -C程序的图形错误
/* 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);
}
}
当我编译它没有错误来。但是当我运行该程序窗口关闭,我得到以下错误: - C:\ TC \ BIN \ TC.EXE NTVDM CPU遇到非法指令..。 。 。 。 。
PLease help
你的turboc中有bgi文件夹吗? –
在XP/Server 2003之后,不要在任何Windows中直接运行任何DOS应用程序。至少使用DosBox。 –
这是无效的C. main()必须返回int,因为这是托管应用程序。 boundary_fill必须返回一个值,它应该有一个函数原型。您应该使用语法包含标准库标题,而不是“stdio.h”。 **您没有正确学习C编程,因为您使用的是过时的非标准编译器!** –
Lundin