1

I am having trouble when trying to run a graphics program through codeblocks. It just opens console and crashes when I click the build&run button. I have tried many other graphics program the result is still the same. And also I tried to debug it and it says segmentation error. See the picture for more details.

picture of the problem

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

int main(void) {
    int gdriver = DETECT, gmode;
    int x1 = 200, y1 = 200;
    int x2 = 300, y2 = 300;
    char driver[] = "";

    initgraph(&gdriver, &gmode, driver);
    line(x1, y1, x2, y2);
    getch();
    closegraph();
    return 0;
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
dip chit
  • 13
  • 3
  • @drescherjm, Probabaly not. Probably just a weird way of doing `const char *driver = "";` – ikegami Dec 18 '19 at 12:51
  • 1
    Possible duplicate of: https://stackoverflow.com/questions/7860569/how-i-can-get-and-use-the-header-file-graphics-h-in-my-c-program – th33lf Dec 18 '19 at 12:51
  • 1
    Does this answer your question? [How I can get and use the header file in my C++ program?](https://stackoverflow.com/questions/7860569/how-i-can-get-and-use-the-header-file-graphics-h-in-my-c-program) – th33lf Dec 18 '19 at 12:52
  • The error is confusing, it is about `std::string` which I don't think the `winbgi` port uses. Could be that your compiler is too new. Remember that the binaries for `winbgi` are now 14 years old. You likely need an old compiler to match. Something from 2005 to 2007 not 2019. – drescherjm Dec 18 '19 at 12:56
  • Please make your title describe the question – Lightness Races in Orbit Dec 18 '19 at 13:02

0 Answers0