DIGIT-ARC read-only archive · snapshot: July 23, 2026

Bgi Error: Graphics not initialized (use initgraph)

4 posts · originally from https://geek.digit.in/community/threads/bgi-error-graphics-not-initialized-use-initgraph.7038/

F
freak_pkp Original post #1
Mar 17, 2005 at 11:13 AM
I have made a program in c++. My program is running fine, but at the
end of the program there is a error message on the screen:

Bgi Error: Graphics not initialized (use initgraph)

My program shows no error message at compile time or at run time.
What's this bgi error? How can I correct this? I have initialized the graphics hardware by using the initgraph function on the main segment
of my program. I am using Borland Turbo c++ compiler 3.1.
[/b]
T
Mar 17, 2005 at 1:13 PM
Code:
For some reason initgraph() failed. To find out why, check
the return value of graphresult(). For example:
#include 
int main(void)
{
    int gerr;   /* graphics error */
    int gdriver = DETECT, gmode;
    /* Initialize graphics using auto-detection and look
    for the .BGI and .CHR files in the C:\TURBOC directory.
    */
    initgraph(&gdriver, &gmode, "C:\\TURBOC");
    if ((gerr = graphresult()) != grOk)
    {
        printf("Error : %s\n", grapherrormsg(gerr));
        exit(1);
    }
    :
}

source: *bdn.borland.com/article/0,1410,17916,00.html
T
Mar 17, 2005 at 11:34 PM
bgi error usually occur when valid graphics driver are not loaded.
using initgraph only not solve this problem, you have to give proper path for bgi graphics drivers which are usually find in bgi folder
use this
initgraph(&gd,&gm,"");
where gd=GRAPHICS DRIVER
gm=GRAPHICS MODE
""=path where driver reside
K
knopixd #4
Mar 18, 2005 at 12:36 AM
bgi error

hey bgi means borland graphics interface.
i think u include graphics.h without writting code for graphics mode
here is the code:
#include"graphics.h"
void main()
{
int d=DETECT,m;
initgraph(&d,&m,"c:\tc\bgi");//or mentioned the path of ur turbo c3
printf("%d",d);//this will display which driver u have (u can check it in graphics.h)
printf("%d",m);//which mode resolution
getch();
}
try it in c extention.....
bye
njoy c man