Search code examples
c++bgiwinbgi

Drawing an arc in C++ Graphics.h


I'm using graphics.h in order to start with a bit of graphic in C++, but when I run the code the program crash. I'm using CodeBlocks as a compiler and Windows 8.1 as an operating system. What should I do in order to make it works? Here is the code:

#include <graphics.h>

int main()
{
    int gd = DETECT;
    int gm;
    initgraph(&gd, &gm, "C:\\TC\\BGI");

    arc(200, 200, 0, 130, 50);

    getch();
    closegraph();
}

Solution

  • "What should I do to make it works?"

    1) Forget about graphics.h it is obsolete.

    2) Get yourself a modern compiler (for example; Clang 7.1, GCC 8.3 or Visual Studio 2017).

    3) Pick a modern graphics library. SFML and SDL are popular options.