Question

I am developing my project in C. On windows-7 I am using DosBox to implement my code. On compile my project doesn't show any error. But when I run my project its simply display the following line on output screen.

bgi error graphics not initialized use initgraph

Here's my code:

void firstscreen()
{
    int gm=DETECT;
    initgraph(&gm,&gm,"");
    floodfill(300,230,RED);
    settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);
    setcolor(BLUE);
    sound(1345);
    outtextxy(100,40,"S.A.JAIN COLLEGE ");
    outtextxy(190,90,"AMBALA CITY");
    settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
    setcolor(GREEN);
    outtextxy(210,230,"PROJECT REPORT ");
    outtextxy(290,265,"ON ");
    outtextxy(240,300,"MOBILE SHOP");
    settextstyle(DEFAULT_FONT,HORIZ_DIR,2);

    setcolor(CYAN);
    settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
    outtextxy(160,400,"Developed By - MAHI");
    setcolor(BLUE);
    settextstyle(1,HORIZ_DIR,1);
    outtextxy(240,440,"Press any key to enter in the program........");
    nosound();
    getch();
    closegraph();
}

void showroom()
{
    int gm=DETECT;
    initgraph(&gm,&gm,"");
    floodfill(300,230,RED);
    settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
    setcolor(BLACK);
    sound(1345);
    outtextxy(240,25,"SHOWROOM");
    outtextxy(240,50,"^^^^^^^^^");
    settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
    setcolor(RED);
    outtextxy(10,85,"Model No       Price(Rs\-)      Color        Wranty");
    settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
    setcolor(GREEN);
    outtextxy(10,125, "X2-01             2300           WHITE           1 YEAR");
    outtextxy(10,155,"X3-02             7800           BLACK           1 YEAR  ");
    outtextxy(10,185,"E5                 4800           BLACK           1 YEAR");
    outtextxy(10,215,"3110              3800           BLACK           1 YEAR  ");
    outtextxy(10,245,"7210              5200           BLACK           1 YEAR");
    outtextxy(10,275,"5233              5800           BLACK           1 YEAR ");
    outtextxy(10,305,"N70               8000           BLACK           1 YEAR");
    outtextxy(10,335,"N72               8800           BLACK           1 YEAR");
    outtextxy(10,365,"N95               10500          BLACK           1 YEAR");
    setcolor(BLUE);
    settextstyle(1,HORIZ_DIR,1);
    outtextxy(440,440,"Press enter......");

    nosound();
    getch();
    closegraph();
}

On SO I saw similar question on this but no answer is accepted by the owner. And also when I try those solutions still same problem. Most of the answers suggest to use path of BGI library. Path of BGI library in my computer.

C:\\TurboC++\\Disk\\TurboC3\\BGI

In my code I am setting path like follow-

int gm = DETECT;
initgraph(&gm,&gm,"C:\\TurboC++\\Disk\\TurboC3\\BGI");

But not working still same problem. Please help me to solve this. Thanks in advance.

Was it helpful?

Solution

Recently I have similar problem. To solve this copy EGAVGA.BGI from BGI folder and paste into BIN folder.

Hope it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top