“无法打开包含文件”是什么意思? Visual C 中的误差平均值++ 2010年?

发布于 2024-10-08 19:47:00 字数 1656 浏览 0 评论 0原文

您能帮我解决以下错误吗:

致命错误 C1083:无法打开包含文件:'graphics.h':没有这样的文件或目录

#include<dos.h>
#include<graphics.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
union REGS in,o;

circ()
{
    int i;
    for(i=0;i<15;i++)
        circle(320,240,i*10);
    rectangle(240,160,400,320);
}

bulb()
{
    int i=1,c=1;
    randomize();
    while(!kbhit())
    {
        if((i%2)==0)
            setcolor(c++);
        setfillstyle(1,getcolor());
        circle(320,240,i*20);
        putpixel(320-i+2,240-i+2,1);
        floodfill(320-i+2,240-i+2,getcolor());
        delay(1000);
        i++;
        if(i>=5)
            i=1;
    }
}

dot()
{
    int i,j,of=40,wid=5;
    setcolor(8);
    setfillstyle(1,getcolor());
    for(i=of;i<getmaxx();i+=of)
        bar(i,0,i+wid,getmaxy());

    for(i=of;i<getmaxy();i+=of)
        bar(0,i,getmaxx(),i+wid);

    for(i=of;i<getmaxx();i+=of)
        for(j=of;j<getmaxy();j+=of)
        {
            setcolor(15);
            setfillstyle(1,getcolor());
            circle(i+2,j+2,4);
            floodfill(i+2,j+2,getcolor());
        }

}

void main()
{
    int x=0,y=10,gd=DETECT,gm,i;
    initgraph(&gd,&gm,"c:\tc\bgi");
    setcolor(YELLOW);
    settextstyle(1,0,6);
    outtextxy(0,240,"Count the black dots.....");
    sleep(4);
    cleardevice();
    dot();
    getch();
    cleardevice();
    setcolor(YELLOW);
    settextstyle(1,0,4);
    outtextxy(0,240,"I bet the lines of rectangle are straight.....");
    sleep(4);
    getch();
    cleardevice();
    circ();
    getch();
    closegraph();
}

Could you please help me in solving the below error:

fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory

#include<dos.h>
#include<graphics.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
union REGS in,o;

circ()
{
    int i;
    for(i=0;i<15;i++)
        circle(320,240,i*10);
    rectangle(240,160,400,320);
}

bulb()
{
    int i=1,c=1;
    randomize();
    while(!kbhit())
    {
        if((i%2)==0)
            setcolor(c++);
        setfillstyle(1,getcolor());
        circle(320,240,i*20);
        putpixel(320-i+2,240-i+2,1);
        floodfill(320-i+2,240-i+2,getcolor());
        delay(1000);
        i++;
        if(i>=5)
            i=1;
    }
}

dot()
{
    int i,j,of=40,wid=5;
    setcolor(8);
    setfillstyle(1,getcolor());
    for(i=of;i<getmaxx();i+=of)
        bar(i,0,i+wid,getmaxy());

    for(i=of;i<getmaxy();i+=of)
        bar(0,i,getmaxx(),i+wid);

    for(i=of;i<getmaxx();i+=of)
        for(j=of;j<getmaxy();j+=of)
        {
            setcolor(15);
            setfillstyle(1,getcolor());
            circle(i+2,j+2,4);
            floodfill(i+2,j+2,getcolor());
        }

}

void main()
{
    int x=0,y=10,gd=DETECT,gm,i;
    initgraph(&gd,&gm,"c:\tc\bgi");
    setcolor(YELLOW);
    settextstyle(1,0,6);
    outtextxy(0,240,"Count the black dots.....");
    sleep(4);
    cleardevice();
    dot();
    getch();
    cleardevice();
    setcolor(YELLOW);
    settextstyle(1,0,4);
    outtextxy(0,240,"I bet the lines of rectangle are straight.....");
    sleep(4);
    getch();
    cleardevice();
    circ();
    getch();
    closegraph();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请帮我爱他 2024-10-15 19:47:00

您正在尝试编译包含头文件graphics.h的代码,但您的编译器找不到该文件。有以下几个可能的原因:

  1. 您在代码文件顶部编写的 include 指令可能不正确。有两种语法形式,您需要确保使用了正确的一种,以便预处理器在正确的位置进行搜索。有关完整的说明,请查看文档

  2. 您可能没有安装 Windows SDK,其中包括从 Win32 API 调用函数所需的头文件。您可以在此处下载最新版本的 SDK。

  3. 我不知道你从哪里得到这段代码,但我所知道的唯一 graphics.h 是一个用于 Borland Turbo C/C++ 编译器极其的旧图形库。它适用于 16 位 MS-DOS 应用程序,而不是现代 Windows 程序。这不是标准的 Windows 标头。您需要使用 windows.h 来代替所有图形函数。

编辑:我看到您已经发布了代码。不幸的是,您也不会很幸运地包含 dos.h。具体参考我上面的第三个建议。我不知道你从哪里得到这段代码,但你无法在 Visual C++ 上编译它。 “Visual”部分意味着您正在创建一个Windows 应用程序。您使用的代码包括在 MS-DOS(Windows 的基于文本的前身)下运行的 Borland Turbo C/C++ 编译器版本中包含的专有头文件。您需要找到一些更新的代码或使用(更)旧的编译器。

如果您绝对需要编译该代码,看起来您可以下载一份 Borland Turbo C++ 3.0 此处。我认为此时它是废弃软件,但你只能靠自己了。很久以前我什至都没有编程。

You are trying to compile code that includes the header file graphics.h, but your compiler cannot find that file. There are a couple of possible reasons why not:

  1. The include directive that you've written at the top of your code file may be incorrect. There are two syntactical forms, and you need to make sure that you've used the right one in order for the pre-processor to search in the correct location. For a complete run-down, check the documentation.

  2. You may not have the Windows SDK installed, which includes the header files you need to call functions from the Win32 API. You can download the latest version of the SDK here.

  3. I have no idea where you got this code, but the only graphics.h that I know about is an extremely old graphics library for Borland Turbo C/C++ compilers. It works with 16-bit MS-DOS applications, not modern day Windows programs. This is not a standard Windows header. You need to be using windows.h instead for all of your graphics functions.

EDIT: I see you've posted your code. Unfortunately, you're not going to have much luck with including dos.h, either. Refer specifically to my third suggestion above. I don't know where you got this code, but you're not going to be able to compile it on Visual C++. The "Visual" part means you're creating a Windows application. The code you're using is including proprietary header files included with versions of Borland's Turbo C/C++ compilers that ran under MS-DOS (the text-based predecessor to Windows). You need to find some updated code or use a (much) older compiler.

If you absolutely need to compile that code, it looks like you can download an ancient copy of Borland Turbo C++ 3.0 here. I assume that it's abandonware at this point, but you're on your own. I wasn't even programming that long ago.

对你而言 2024-10-15 19:47:00

graphics.hconio.h 都只能在 Borland 编译器上使用(它们是供应商特定的扩展)。

(注意:我相信 conio.h 实际上存在于最近的 msvc++ 编译器上,但它与 Borland 的版本不是 100% 兼容)

如果您使用 MSVC,您将必须使用来实现您的逻辑改为 Windows API 的控制台函数

Both graphics.h and conio.h are only available on Borland compilers (they are vendor specific extensions).

(Note: I believe conio.h actually exists on recent msvc++ compilers, but it's not 100% compatible with Borland's version)

If you're using MSVC, you're going to have to implement your logic using the Windows API's Console Functions instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文