"Type mismatch in parameter" 何时使用 setfillpattern()?

"Type mismatch in parameter" when using setfillpattern()?

我已经开始使用 C 项目来构建吃豆人游戏,但是当我执行以下代码时出现错误。该错误由 Code::Blocks 和 Turbo C++ 3.5 生成。 在 Code::Blocks 中,我删除了 "C:\TurboC3\BGI" 的路径,但错误仍然存​​在。

Turbo C++ 错误

错误 Code::Blocks

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int main()
{
    int gd=0,gm;
    initgraph(&gd,&gm,"C:\TurboC3\BGI");
    setfillpattern(SOLID_FILL,YELLOW);
    circle(200,100,10);
    line(200,250,200,250);
    line(225,250,225,250);
    line(250,250,250,250);
    line(275,250,275,250);
    line(300,250,300,250);
    line(325,250,325,250);
    arc(50,225,110,-100,30);
    printf("Hello...Let's Play PacMan !! \n\n");
    getch();
    closegraph();
    return 0;
}

我不使用 BGI,但快速搜索发现 setfillpattern is expecting a char array as the first parameter, but SOLID_FILL is of type enum fill_styles. To use SOLID_FILL you need to call setfillstyle

要使用 setfillpattern,您需要提供自定义模式:

char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x24, 0x24, 0x07, 0x00};
setfillpattern(pattern, YELLOW);