-1

I have started working on a C project to build a PacMan game, but I am getting an error when I execute below code. The error is generated by Code::Blocks as well as Turbo C++ 3.5. In Code::Blocks I remove the path which is "C:\TurboC3\BGI",but the error still continues.

Error in Turbo C++ Turbo C++ error

Error in Code::Blocks Error in 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;
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
Harsh patel
  • 445
  • 5
  • 11
  • 2
    Post the error you are getting. – 001 Oct 11 '17 at 13:52
  • 8
    Turbo C++? BGI? I think you should take a look at the calendar. Its the wrong millennia. – Eugene Sh. Oct 11 '17 at 13:52
  • I have Added Error images @JohnnyMopp you can now refer to them. – Harsh patel Oct 11 '17 at 14:02
  • 1
    Check the prototype: [setfillpattern(char *upattern, int color)](https://www.cs.colorado.edu/~main/bgi/doc/setfillpattern.html). – 001 Oct 11 '17 at 14:04
  • Please can you elaborate your comment ?, I'm facing difficulty understanding it. @JohnnyMopp – Harsh patel Oct 11 '17 at 14:32
  • Your image of text [isn't very helpful](//meta.unix.stackexchange.com/q/4086). It can't be read aloud or copied into an editor, and it doesn't index very well, meaning that other users with the same problem are less likely to find the answer here. Please [edit] your post to incorporate the relevant text directly (preferably using copy+paste to avoid transcription errors). – Toby Speight Oct 11 '17 at 16:20
  • Where is `SOLID_FILL` defined? It's obviously not the type that `setfillpattern` expects. – John Bode Oct 11 '17 at 16:36

1 Answers1

3

I don't use BGI, but a quick search finds that 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 instead.

To use setfillpattern you need to supply a custom pattern:

char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x24, 0x24, 0x07, 0x00};
setfillpattern(pattern, YELLOW);
001
  • 13,291
  • 5
  • 35
  • 66