C语言 BGI错误,如何解决?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7605942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 09:45:50  来源:igfitidea点击:

BGI error, How to Resolve it?

cturbo-cbgi

提问by sriram

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 :

我想运行一个绘制圆的 C 程序。该程序正在编译且没有错误并且正在运行。从用户获取半径等值后,我收到如下错误:

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

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?

我正在使用 Windows,但我无法弄清楚我哪里出错了。任何人都可以在这方面帮助我吗?

Thanks in advance.

提前致谢。

回答by Jesus Ramos

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

你的路径initgraph是错误的。使用"c:\\tc\bgi"来代替。

回答by Theja

Try this (it worked for me) :

试试这个(它对我有用):

The BGI folder is usually in the following path,

BGI文件夹通常在以下路径中,

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

C:\TurboC++\磁盘\TurboC3\BGI

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

所以你需要在你的程序中放入的代码如下,

initgraph(&gd, &gm, "C:\TurboC3\BGI");

回答by montej

I also suffered from that problem.

我也遇到了这个问题。

Simply put this line:

简单地说这一行:

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

here c:\tc\bgiis important.

这里c:\tc\bgi很重要。

MOST IMPORTANT:

最重要的:

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

tc.exe(您正在使用的)顶部是一些菜单,如文件、编辑、选项:

  • 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.

注意:在输出中,如果它给出了关于bgi的错误,请忽略它,如果需要,只需为程序提供输入,它就会为您提供图形输出。享受。

回答by Gautam Jangra

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

如果您在运行图形程序时收到此错误消息: 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.

只需将\tc\bgi\EGAVGA.BGI 文件复制到运行应用程序的本地文件夹即可。

回答by Alexey Frunze

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)
  • bgi 文件的错误路径(我看到冒号丢失)
  • 不支持的图形模式(不要指望 DOS 图形应用程序在 Vista 及更高版本下工作)

回答by payal

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

如果包含 "C:\tc\bgi" 仍然存在错误,请尝试以下操作:转到文件-> 更改目录.. 将其更改为 bgi .. 但每次打开 turboc 时都必须这样做