This code is used to draw a polygon from given points

I've already imported the winBGIm library and pasted the 3 files in the lib and include. Also made changes to the linker options in compiler. It shows an error saying "program.exe" has stopped working." and closes after a few seconds.

#include<stdio.h>
#include<graphics.h>
using namespace std;

int main()
{
    printf("\t\t\t---PROGRAM TO CONVERT GIVEN POINTS TO POLYGON--- \n");
    int n,i;
    int m=n+2;

    printf("\n Enter number of points to be converted to a n-shaped 
polygon");
    int points[m];

    printf("\n Enter the points in the FORMAT(X,Y) for each coordinate");
    for(i=0;i<n;i++)
    {
        scanf("%d",&points[i]);
    }
    points[n]=points[0];
    points[n+1]=points[1];

    int gd=DETECT, gm;

    initgraph(&gd,&gm,NULL);
    int o=n+1;
    drawpoly(o ,points);

    getch();

    closegraph();
}

Need a graphical output of a polygon

0 Answers