BGI error, How to Resolve it?
Asked Answered
F

6

9

I want to run a C program that draws a circle. The program is compiling with no error and it is running. After getting the values like radius from the user, I get the error like this :

BGI error: Graphics not initialized ( use "initgraph")

Even though in my source code I have added this line :

int gmode,gdrive=DETECT;
initgraph(&gdrive,&gmode,"c\\tc\\bgi");

Still I'm getting error.

I'm using Windows and I couldn't figure out where I went wrong. Can anyone help me in this regard?

Thanks in advance.

Figurehead answered 30/9, 2011 at 4:27 Comment(7)
C:\\tc\\bgi you mean this path right?Deepfry
@JesusRamos Oh I'm a novice in C graphics so i'm not sure. So whats the correct path?Figurehead
In windows your path starts with Drive:\\path\\to\\folder if you want a literal string of itDeepfry
Did you just copy that without fixing it? stackoverflow.com/questions/3316337/c-program-line-not-drawing/…Scare
@HansPassant : Yes to be honest. Since I'm a novice thought it was a correct.Figurehead
@HansPassant Wow that's quite a find.Deepfry
@Jesus, credit to the OP for upvoting it today. Not for reading it :)Scare
D
8

Your path in initgraph is wrong. Use "c:\\tc\bgi" instead.

Deepfry answered 30/9, 2011 at 4:34 Comment(3)
Backslashes must be escaped in literals.Babbette
@Alex Yeah I forgot the markup on here messes up the backslashes (you have to use 4 to get 2) thanksDeepfry
otherwise copy BGI folder content into BIN folderGorse
S
4

If you get this error message when you run your graphics program: BGI Error: Graphics not initialized (use 'initgraph')

Just you need to copy the \tc\bgi\EGAVGA.BGI file to your local folder where you are running the application.

Sassy answered 20/1, 2013 at 15:26 Comment(1)
the other solutions didn't work but this worked for me running turbo c++ in dosbox on max os high sierraHamer
E
2

Try this (it worked for me) :

The BGI folder is usually in the following path,

C:\TurboC++\disk\TurboC3\BGI

So the code you need to put in your program is as follows,

initgraph(&gd, &gm, "C:\\TurboC3\\BGI");
Erythropoiesis answered 9/9, 2013 at 11:5 Comment(0)
H
1

I also suffered from that problem.

Simply put this line:

initgraph(&gdrive,&gmode, "c:\tc\bgi"); 

here c:\tc\bgi is important.

MOST IMPORTANT:

In tc.exe (which you are using) at top are some menus like file, edit, options:

  • Go options>application
  • select overlay (By Default it is "standard" but you must select "overlay" option), then click on ok.
  • now you run your graphics progaram.

NOTE: in the output, if it gives an error about bgi, ignore it, just give the input for the program if it is required and it will give you the graphics output. Enjoy.

Hapsburg answered 15/9, 2012 at 11:6 Comment(0)
B
0

Could be multiple reasons:

  • wrong path to the bgi file (I see the colon is missing)
  • unsupported graphics mode (don't expect DOS graphics apps to work under Vista and up)
Babbette answered 30/9, 2011 at 4:34 Comment(0)
J
0

if by including "C:\tc\bgi" still the error persists , try this: goto file-> change directory.. change it to bgi.. but this has to be done every time u open the turboc

Jenkins answered 2/3, 2014 at 4:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.