c++ - graphics.h 没有输出

标签 c++ c bgi

#include <graphics.h>
#include <conio.h>


int main()

{
    int gd = DETECT, gm;
    initgraph(&gd,&gm, "");
    for (int i=200;i<400;i=i+25)
    {
        for (int j=200;j<400;j=j+25)
        {
            circle(i,j,100);
        }
    }
    getch();
    closegraph();

    return 0;
}
我下载http://winbgim.codecutter.org/
提取和复制粘贴
graphics.h
winbgim.h
libbgi.a
我设置Settings => Compiler => Linker设置。并添加 -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32我将第 302 行更改为 int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,我使用 .cpp 而不是 .c 但仍然没有输出
output

最佳答案

你的代码很完美。您只是忘记为 提供路径BGI 文件夹 .
在我的机器 BGI 路径是 "C:\TurboC++\Disk\TurboC3\BGI" .因为我在 上运行它DOSBox .所以路径变为"C:\\TurboC3\\BGI"这是工作代码。

#include <graphics.h>
int main()
{
    int gd = DETECT, gm, i, j;
    initgraph(&gd,&gm, "c:\\TurboC3\\BGI");
    for (i=200;i<400;i=i+25)
    {
        for (j=200;j<400;j=j+25)
        {
            circle(i,j,100);
        }
    }
    getch();
    closegraph();
    return 0;
}
BGI(Borland 图形界面):- windows机器的图形界面。其中定义了 circle()、arc()、line() 等函数。 graphics.h就像驱动程序来绘制图形和使用 BGI 接口(interface)。
您收到错误 BGI Error: Graphics not initialized (use 'initgraph') .你看不到它,因为屏幕很快就出来了。在 TurboC 点击 Window最右上角的选项。然后点击Output .然后输出窗口将在底部。
错误:-
enter image description here
输出:-
enter image description here

关于c++ - graphics.h 没有输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65020753/

相关文章:

c - 带有指针的 strcmp 在 C 中不起作用

c++ - 将地址转换为函数 : using "void * void "

c - 是 x=;而if(d<)在c语言中使用无效

c++ - 递减折叠表达式内的模板参数

c++ - 没有类减法运算符重载但仍然有效

无法理解为什么我在 C 中使用 struct offset 得到这些结果

c++ - Hermite 曲线中的切线值

c++ - Linux 下的 C C++ 图形程序

c++ - SDL 只会在尝试打印图片时绘制黑屏 C++

c++ - 在 C++ 中计算球体的体积