0

我正在用 C 语言开发我的项目。在 windows-7 上,我使用 DosBox 来实现我的代码。在编译我的项目时没有显示任何错误。但是当我运行我的项目时,它只是在输出屏幕上显示以下行。

bgi error graphics not initialized use initgraph

这是我的代码:

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();
}

在 SO 我看到了类似的问题,但所有者没有接受任何答案。而且当我尝试这些解决方案时仍然存在同样的问题。大多数答案都建议使用 BGI 库的路径。我电脑中 BGI 库的路径。

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

在我的代码中,我正在设置如下路径-

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

但不工作仍然是同样的问题。请帮我解决这个问题。提前致谢。

4

1 回答 1

1

最近我有类似的问题。要解决此复制EGAVGA.BGIBGI folder粘贴到BIN folder.

希望它有效。

于 2014-03-05T10:28:24.510 回答