1
#include <graphics.h>
#include <conio.h>


int main()

{
    int gd = DETECT, gm;
    initgraph(&gd,&gm, "");
    for (int i=200;i<400;i=i+25)
    {
        for (int j=200;j<400;j=j+25)
        {
            circle(i,j,100);
        }
    }
    getch();
    closegraph();

    return 0;
}

I download http://winbgim.codecutter.org/ extract and copy-paste

graphics.h
winbgim.h
libbgi.a

I set Settings => Compiler => Linker settings. and add -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32 I change line 302 as int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX, and im using .cpp not .c but there is still no outputs output

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • You might consider checking for errors as shown in the example here: http://winbgim.codecutter.org/V6_0/doc/initgraph.html It might also be better to start small. Draw one circle and if that works then you can incrementally change things and see where it breaks. – Retired Ninja Nov 26 '20 at 11:16
  • This [Microsoft page](https://learn.microsoft.com/en-us/troubleshoot/previous-versions/visualstudio/foxpro/c0000005-error-troubleshoot) says "A C0000005 error is memory error. Specifically, a C0000005 error is an access violation error caused by a buffer overrun." – Weather Vane Nov 26 '20 at 11:17
  • What should i do about A C0000005 error @WeatherVane dont understand solution in Microsoft page –  Nov 26 '20 at 11:55
  • i copy-paste the example at winbgim.codecutter.org/V6_0/doc/initgraph.html but still nothing out @RetiredNinja –  Nov 26 '20 at 11:56
  • Setting `left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX` is unwise. It needs `4611686014132420609` pixels for a 32-bit `int`. – Weather Vane Nov 26 '20 at 11:59
  • okey so what settings should i use –  Nov 26 '20 at 12:01
  • i also download and set compiler TDM-GCC-32 but still nothing outs –  Nov 26 '20 at 12:02
  • Getting this ancient crap to run on modern PC is probably 10 times harder than learning the basics of some modern GUI library which is actually used in the real world. Do you wish to learn GUI programming or do you wish to learn how to become a MS DOS emulator installer? – Lundin Nov 26 '20 at 13:34
  • lol i should give up and learn c++ or python @Lundin –  Nov 26 '20 at 15:55
  • @lordwile Which GUI library to use doesn't have anything to do with choice of programming language. BGI is an ancient graphics library for Borland compilers. It worked with C, C++, Pascal and probably some other languages too. – Lundin Nov 27 '20 at 13:38
  • @lordwile if you're satisfied with my answer then you can mark it as accepted. – Deepak Gautam Nov 28 '20 at 08:01

1 Answers1

2

Your code is perfect. You just forget to give path for BGI folder. In my machine BGI path is "C:\TurboC++\Disk\TurboC3\BGI". Since I am running it on DOSBox. So path becomes "C:\\TurboC3\\BGI"

Here is the working code.

#include <graphics.h>
int main()
{
    int gd = DETECT, gm, i, j;
    initgraph(&gd,&gm, "c:\\TurboC3\\BGI");
    for (i=200;i<400;i=i+25)
    {
        for (j=200;j<400;j=j+25)
        {
            circle(i,j,100);
        }
    }
    getch();
    closegraph();
    return 0;
}

BGI (Borland Graphics Interface):- Graphics interface for windows machine. Functions like circle(), arc(), line() etc are defined in it. graphics.h is like driver to draw graphics and use BGI interface.

You're getting error BGI Error: Graphics not initialized (use 'initgraph'). You can't sees it because screen quickly out. In TurboC click on Window option at right top most. And then click on Output. Then output window will be at the bottom.

Error:- enter image description here

Output:- enter image description here

Deepak Gautam
  • 1,309
  • 12
  • 14