''DETECT' keyword errors in BoundaryFill Algorithm

I want to use boundary fill algorithm with cpp in Visual Studio Environment. I tried to run some code parts for it, but I faced to face an error at every turn. This error is about 'DETECT' keyword in codes. The most of codes include that lines:

int gd=DETECT,gm,n,ch,xc,yc,r,bcolor,fcolor;
initgraph(&gd,&gm,"");

I have an error as "the definition 'DETECT' is undefined" because of this usage.

How can I overcome this problem?

PS: You can reach example code that I used from this link -> http://www.hhhprogram.com/2013/05/draw-circle-and-fill-color-using-boundary-fill-algorithm.html

Thank you.



Solution 1:[1]

add header for DETECT, that may solve the issue.

Solution 2:[2]

I think this code is Turbo C++ specific ( will work with Turbo C++ only) and will not work in Visual Studio unless you add proper library which contains those BGI.h and initgraph and gd= DETECT blah blah blah whatever you are using.

To draw graphics in your C program you should have some graphics library with your C compiler. Normally you have to download that and link to the compiler yourself. Turbo C++ by default contains graphics.h which provides some basic graphics functions. If you want to use that in your Visual C++ compiler you have to add that so that Visual C++ compiler can recognize what initgraph, gd = DETECT is. I do not know how to add graphics.h in Visual C++ and I would not recommend that. I won't recommend using turbo c++ either. Instead, you can download and install OpenGL with your Visual studio. If you want simpler thing then go for Dev-Cpp and Allegro.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sigcont
Solution 2 Barshan Das