'graphics.h gives no output
#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
Solution 1:[1]
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.
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 | Deepak Gautam |


